need for using is_uploaded_file() function while uploading in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dinesh1985singh
    New Member
    • Apr 2010
    • 49

    need for using is_uploaded_file() function while uploading in php

    hello eveybody,

    what is the actual need of usingfunction is_uploaded_fil e($_FILES["userfile"]["te mp_name"] ,

    I know it return turn if the file was uploaded via http ,and false otherwise.

    If i would not this function ,even then we can upload file successfully.
    I guess some security reason behind this.

    So please help me out in this regard.


    Thank you
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    That function is meant to verify that a file was uploaded via a HTTP request. If you are using the move_uploaded_f ile function to move the uploaded file before using it, this function is not needed. It's primarily used in cases where the temporary location of the uploaded file needs to be used in your code.

    For example, if a data file is uploaded, so that it's contents can be saved into a database, after which the file itself is discarded, then in makes little sense to actually move the file before using it. The code would verify that the file was indeed uploaded, using this function, read it's content's from the temporary location, and then just delete it.

    Comment

    • dinesh1985singh
      New Member
      • Apr 2010
      • 49

      #3
      Originally posted by Atli
      Hey.

      That function is meant to verify that a file was uploaded via a HTTP request. If you are using the move_uploaded_f ile function to move the uploaded file before using it, this function is not needed. It's primarily used in cases where the temporary location of the uploaded file needs to be used in your code.

      For example, if a data file is uploaded, so that it's contents can be saved into a database, after which the file itself is discarded, then in makes little sense to actually move the file before using it. The code would verify that the file was indeed uploaded, using this function, read it's content's from the temporary location, and then just delete it.
      Thank you Atli
      I got your point,
      Now I am sure when to use this function.

      Great reply
      Thank you

      Comment

      Working...