Multiple file upload

Discussion in 'PHP' started by rps111, Jul 25, 2007.

  1. #1
    Hi all.
    I am a PHP newbie and require some help from you. Actually I am developing a website for file sharing. I have a limited period of access to the internet during the day so I can not upload the files one-by-one.

    Is there a way that I can simultaneously upload multiple files to my site that can create multiple posts.

    e.g. I have to upload 25 e-books and add the description of the book (author, publisher, year of publication etc.). One way to do is fill a form and upload the file one-by-one. But due to the limited time I can spend online, is there a way to do most of this stuff offline and have to do the minimum things when I am online.
     
    rps111, Jul 25, 2007 IP
  2. norfstar

    norfstar Peon

    Messages:
    1,154
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yep, PHP supports multiple file uploads in one post. Simply add more file inputs to your form, give them different names, and have the PHP script handle them in the same way it handles your single existing uploaded file.
     
    norfstar, Jul 25, 2007 IP
  3. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #3
    Something like this works.

    
    for($num = 1; $num <= 25; $num++)
    {
      echo "<input type='file' name='file'".$num."'>";
    }
    
    
    PHP:
    
    for($num = 1; $num <= 25; $num++)
    {
      $name = $_FILES['file'.$num]['name'];
    }
    
    PHP:
     
    exodus, Jul 25, 2007 IP
  4. rps111

    rps111 Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks norfstar and exodus....but how can i add them to different categories...e.g., one book needs to go in the section Programming>PHP, other book to Database>MySQL, the third book to Biology>Medicine>Critical Care, the fourth book to Physics>Astronomy>Relativity Theory....and so on.....Is it possible to add them to different categories right from a single page (much like...say I have to make different posts in DP in different categories simultaneously).
     
    rps111, Jul 26, 2007 IP