Results 1 to 2 of 2

Thread: Uploading Multiple Files

  1. #1
    Join Date
    Sep 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Uploading Multiple Files

    Hi.. I found this script that allows you to upload multiple files. It only displays one upload form at a time, and thanks to javascript, starts a list of all the files you selected. THIS works fine... The only drawback to this cool script is that it formats the $_FILES data by naming each upload differently (the name property in the HTML file input is fixed for every upload box as "file_0", "file_1", "file_2" and so on...), instead of using the same name, and indexing the multiple files. Since I dont want to go through the other authors JavaScript, i've been trying to write my php to adjust accordingly.. What I have works just fine. It creates the customer's directory just fine, however it doesn't put anything inside of it, but it doesn't give me any errors on the move_uploaded_file, and it shows the files array in full when I print_r($_FILES)... what's going on here???

    Heres my code:

    $numFiles = $_GET['numFiles'];
    $orderId = $vars['orderID'];
    $destDir = "uploads/".$orderId;


    mkdir($destDir, 0777);

    for ($i=0; i<$numFiles; $i++) {
    $file = "file_".$i;
    $name = basename($_FILES[$file]['name']);
    $location = $destDir.'/'.$name;
    if (move_uploaded_file($_FILES[$file]['tmp_name'], $location)){
    @chmod($location, 0775);
    } else { die('Upload Failed. '.mysql_error());}
    }
    @chmod($destDir, 0775) or die('Error on chmod....');

    #REST OF CODE...

  2. #2
    Join Date
    Sep 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default nevermind, got it...

    missing a $ infront of the i....

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •