Help in Image Upload...!

Discussion in 'PHP' started by actress143, Jun 6, 2010.

  1. #1
    in image upload code i found these lines...

    
    
    if ($_FILES["file"]["error"] > 0)
        {
        echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
        }
    
    
    PHP:
    Except this part, i understand every thing...
    any body explain this part to me..,

    what is $_FILES["file"]["error"],

    why used > 0

    and what echo will retuens....! i am very fresher so please tell me clearly


    Thanks friends..,
     
    actress143, Jun 6, 2010 IP
  2. Sergey Popov

    Sergey Popov Peon

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Since PHP 4.2.0, PHP returns an appropriate error code along with the file array. The error code can be found in the error segment of the file array that is created during the file upload by PHP. In other words, the error might be found in $_FILES['file']['error'].

    If $_FILES['file']['error'] is 0 - this means file was uploaded successfully, no errors.

    Source: http://www.php.net/manual/en/features.file-upload.errors.php
     
    Sergey Popov, Jun 6, 2010 IP
  3. actress143

    actress143 Peon

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    But $_FILES["file"]["error"] > 0

    the error will be executed.. according to the code i provided...!
    as

    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";


    But you said
    If $_FILES['file']['error'] is 0 - this means file was uploaded successfully, no errors.
     
    actress143, Jun 6, 2010 IP
  4. Sergey Popov

    Sergey Popov Peon

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You're right. If $_FILES["file"]["error"] > 0 your script will display error code:

    
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    
    Code (markup):
    If there was no errors during file upload, the variable $_FILES["file"]["error"] will be set to zero, meaning your code will not display error code.
    Isn't it obvious? :)
     
    Sergey Popov, Jun 6, 2010 IP
  5. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Its says that if the value is greater that 0 it will return a Error Number
    Else (if equal to 0) means Upload successful
     
    roopajyothi, Jun 6, 2010 IP
  6. actress143

    actress143 Peon

    Messages:
    132
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Ohh ya ..., thank you roopajyothi, and Sergey Popov..!

    Now i came to know exactly..., thanks once again..!
     
    actress143, Jun 6, 2010 IP
  7. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #7
    roopajyothi, Jun 6, 2010 IP