+ Reply to Thread
Results 1 to 4 of 4

Thread: Uploading multiple files

  1. #1
    equipemis is offline x10Hosting Member equipemis is an unknown quantity at this point
    Join Date
    Oct 2009
    Posts
    12

    [SOLVED]Uploading multiple files

    Hi guys,

    I have a problem. I am trying to upload 8 files at the same time.

    So I have this as my form:
    Code:
    <form action="upload.php" ENCTYPE="multipart/form-data" method="post">
    players.ehm: <input id="file1" type="file" name="file1"><br/>
    teams.ehm: <input id="file2" type="file" name="file2"><br/>
    statistics.ehm: <input id="file3" type="file" name="file3"><br/>
    league.ehm: <input id="file4" type="file" name="file4"><br/>
    schedule.ehm: <input id="file5" type="file" name="file5"><br/>
    histories.ehm: <input id="file6" type="file" name="file6"><br/>
    draftpicks.ehm: <input id="file7" type="file" name="file7"><br/>
    <input type="submit" value="Upload!">
    And this is upload.php:
    Code:
    <?php
    $directory_self = getcwd();
    for($i = 1; $i < 8; $i++){
    $file_name = $_FILES['file'. $i]['name'];
    // strip file_name of slashes
    $file_name = stripslashes($file_name);
    $file_name = str_replace("'","",$file_name);
    $copy = move_uploaded_file($_FILES['file'. $i]['tmp_name'],$directory_self);
     // prompt if successfully copied
    }
    if($copy){
    print "Les fichiers ont ete uploader<br/><a href='start_update.php'>Continuer</a>";
    }
    else
    {
    echo "Une erreur s'est produite!</br> <a href='form.php'>Re-essayer</a>";
     }
    ?>

    But I get this error:
    Warning: move_uploaded_file(/home/equipemi/public_html/converter) [function.move-uploaded-file]: failed to open stream: Is a directory in /home/equipemi/public_html/converter/upload.php on line 8

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpMD388V' to '/home/equipemi/public_html/converter' in /home/equipemi/public_html/converter/upload.php on line 8
    The converter folder has 777 of permission so does the upload.php file.


    Thanks for your help,
    Last edited by equipemis; 01-27-2010 at 03:04 PM.

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Uploading multiple files

    The second arguement to move_uploaded_file is the name of the destination file, not a directory (as you have it).

    Sort of like

    Code:
    $copy = move_uploaded_file($_FILES['file'. $i]['tmp_name'],$directory_self . '/' . $file_name );
    but you should double check you are not overwriting an existing file.
    You should also sanitize the input a bit more.
    Last edited by descalzo; 01-27-2010 at 02:50 PM.
    Nothing is always absolutely so.

  3. #3
    slacker3 is offline x10 Sophmore slacker3 is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    146

    Re: Uploading multiple files

    $directory_self is just the destination directory, you have to provide an filename too.

    EDIT:
    http://php.net/manual/en/function.mo...oaded-file.php
    Last edited by slacker3; 01-27-2010 at 02:51 PM.

  4. #4
    equipemis is offline x10Hosting Member equipemis is an unknown quantity at this point
    Join Date
    Oct 2009
    Posts
    12

    Re: Uploading multiple files

    Thanks it works!!!

+ Reply to Thread

Similar Threads

  1. Problems uploading files with FTP
    By rodrigu5 in forum Free Hosting
    Replies: 3
    Last Post: 01-08-2010, 10:47 PM
  2. Question about uploading files
    By keyser318 in forum Free Hosting
    Replies: 6
    Last Post: 11-12-2009, 01:14 PM
  3. Uploading HTML files
    By newm20 in forum Free Hosting
    Replies: 2
    Last Post: 05-17-2009, 07:59 AM
  4. Uploading files with HTTP -> error 406 : Not Acceptable
    By similitux in forum Free Hosting
    Replies: 1
    Last Post: 08-18-2008, 02:38 PM
  5. uploading files
    By playdnd in forum Free Hosting
    Replies: 0
    Last Post: 12-16-2007, 06:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers