1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

file upload

Discussion in 'PHP' started by lammspillning, Jun 2, 2009.

  1. #1
    I have this code to take care of my files I upload on my server. But sometimes files get skipped and won't upload. How can I in that case retry the script to give the file a new shot?
    move_uploaded_file($_FILES['Filedata']['tmp_name'], "../media/uploads/". $myVariable. ".jpg");
    PHP:

     
    lammspillning, Jun 2, 2009 IP
  2. tguillea

    tguillea Active Member

    Messages:
    229
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #2
    Your best bet is to simply check if the file exists, and then redirect them back to the upload page if it failed.

    this should do the trick
    
    if (file_exists($_FILES['Filedata']['tmp_name'])){
        move_uploaded_file($_FILES['Filedata']['tmp_name'], "../media/uploads/".$myVariable. ".jpg");
        } else {
        header('location: upload.php');
        exit();
        }
    
    PHP:
     
    tguillea, Jun 3, 2009 IP