Closed Thread
Results 1 to 5 of 5

Thread: How to upload a file using a PHP script??

  1. #1
    bishisht is offline Newbie
    Join Date
    Apr 2010
    Location
    Kathmandu,Nepal
    Posts
    23
    Rep Power
    0

    How to upload a file using a PHP script??

    can anyone tell me how can I design a simple form through PHP that can upload pdf/doc file to a server using database along with the data submitted in the form?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Digwnews is offline Newbie
    Join Date
    Sep 2010
    Location
    Russia, Moscow
    Posts
    1
    Rep Power
    0

    Re: How to upload a file using a PHP script??

    What's the problem?

    upload.php
    Code:
    <?php
    if(!$_POST['go'])
    {
    echo 
    '<form action=upload.php method=post enctype=multipart/form-data>
    <input type=hidden name=go value=go>
    <input type=file name=uploadfile>
    <input type=submit value=Upload></form>'
    ;
    }
    else
    {
    copy($_FILES['uploadfile']['tmp_name'],"uploads/".basename($_FILES['uploadfile']['name']));
    echo 
    'Uploaded!';
    }
    ?>
    File will be in "uploads" directory.

  4. #3
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Posts
    3,087
    Blog Entries
    7
    Rep Power
    42

    Re: How to upload a file using a PHP script??

    But it wasn't saving to file that was asked for...
    but these two tutorials help you out good:
    Tutorial: Storing Images in MySQL with PHP
    Tutorial: Storing Images in MySQL with PHP / Part II / Display your images
    __________________________________________
    I study Information Systems at Karlstad University when I'm not on CodeCall

  5. #4
    bishisht is offline Newbie
    Join Date
    Apr 2010
    Location
    Kathmandu,Nepal
    Posts
    23
    Rep Power
    0

    Unhappy Re: How to upload a file using a PHP script??

    copy($_FILES['uploadfile']['tmp_name'],"uploads/".basename($_FILES['uploadfile']['name']));


    well m confused in this line. how the two variables uploadfile and tmp_name works?

  6. #5
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Posts
    3,087
    Blog Entries
    7
    Rep Power
    42

    Re: How to upload a file using a PHP script??

    uploadname is the name of the input tag in your html, tmp_name contains a randomized name of the file while temporary stored on the server to be handled by you.
    you can try print_r($_FILES) and see how the array looks like and what info you can receive from the file upload process.
    __________________________________________
    I study Information Systems at Karlstad University when I'm not on CodeCall

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [PHP] Base Multiple File Upload Script
    By DEViANT in forum Classes and Code Snippets
    Replies: 2
    Last Post: 10-16-2010, 01:21 AM
  2. Upload Script?
    By BASHERS33 in forum PHP Development
    Replies: 8
    Last Post: 08-30-2009, 08:36 AM
  3. file upload script question
    By Xhris in forum PHP Development
    Replies: 15
    Last Post: 12-07-2008, 07:54 AM
  4. Upload Script Help..
    By coated_pill in forum PHP Development
    Replies: 1
    Last Post: 07-14-2008, 08:46 AM
  5. Replies: 7
    Last Post: 05-04-2008, 07:44 AM

Tags for this Thread

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