SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unable to upload multiple files using POST

    Hi all...i have a problem in uploading multiple files

    my file uploading page has a form with code

    PHP Code:
    <?php    for($i=0;$i<num;$i++)      //<-------------------------------------------num determined at runtime
    {
               echo 
    'Upload file :';    ?>
               <input name="userfile[]" type="file"  />
    <?php }  ?>

    I submit it and for handling this i used:
    I have a folder 'uploads'

    PHP Code:
    <?php
    $uploads_dir 
    '/uploads';
    foreach (
    $_FILES["userfile"]["name"] as $key => $name) {
        {
            
    $tmp_name $_FILES["userfile"]["tmp_name"][$key];
            
    $name $_FILES["userfile"]["name"][$key];
            
    move_uploaded_file($tmp_name"$uploads_dir/$name");
        }
    }
    ?>

    but i get the error message

    Warning: move_uploaded_file(/uploads/5.l) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/harsh/public_html/testroom/fileContainer.php on line 7

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpfGSibR' to '/uploads/5.l' in /home/harsh/public_html/testroom/fileContainer.php on line 7



    please help me out of it..I am not sure if the file handling code is correct because i copied and modified a code from php.net
    Last edited by SpacePhoenix; Sep 20, 2011 at 23:06. Reason: placed php tags around the php code

  2. #2
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,072
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Have you set the file permissions of the destination folder to allow writing?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator


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
  •