File upload errors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mumo
    New Member
    • Aug 2006
    • 4

    File upload errors

    Hi all,

    I am just starting with this programming language.
    I was trying to write an upload script to the server but the code is not working. Here is a sample of the code am using to upload the picture:


    [PHP]
    $put_file = (move_uploaded_ file($HTTP_POST _FILES['user_file]['tmp_name'],"../uploads/$HTTP_POST_FILE S['user_file']['name'];

    if ($put_file){
    echo "Your upload was successful";
    } else {
    echo "Sorry, an error occured so your file could not be uploaded";
    }
    [/PHP]

    Please help. :)
    Last edited by Niheel; Aug 25 '06, 03:47 AM.
  • vssp
    Contributor
    • Jul 2006
    • 268

    #2
    Hi friend Try this program

    <?php
    // In PHP earlier then 4.1.0, $HTTP_POST_FILE S should be used instead of
    // $_FILES. In PHP earlier then 4.0.3, use copy() and is_uploaded_fil e()
    // instead of move_uploaded_f ile

    $uploaddir = '/var/www/uploads/';
    $uploadfile = $uploaddir. $_FILES['userfile']['name'];

    print "<pre>";
    if (move_uploaded_ file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    print "File is valid, and was successfully uploaded. ";
    print "Here's some more debugging info:\n";
    print_r($_FILES );
    } else {
    print "Possible file upload attack! Here's some debugging info:\n";
    print_r($_FILES );
    }
    print "</pre>";

    ?>

    Comment

    • Mumo
      New Member
      • Aug 2006
      • 4

      #3
      Hi friend,
      Thanks for your help, I am trying to change my code as and finding out the server version am using so i can get passed this problem. Thank you so much....

      Comment

      • vssp
        Contributor
        • Jul 2006
        • 268

        #4
        Thanks welcome

        Comment

        • Mumo
          New Member
          • Aug 2006
          • 4

          #5
          I have changed my code accordingly. But after putting a switch statement for error checking, am getting the error "Cant write to Disk". I dont know what to do to make this work anymore. What could be the possible causes of this error. Am willing to try anything possible to get this working coz it is becoming frustrating for me.

          Thanks for your help

          Comment

          • vssp
            Contributor
            • Jul 2006
            • 268

            #6
            I thnik folder permission related issue.
            So u give the full permission on uploaded folder

            Comment

            Working...