Jump to content

file_exists


eranwein

Recommended Posts

i need to check if an uploaded file exists.
i'm using file_exists($filename).
as i understand, the $filename should be the path and name of the uploaded file.
$_FILES['uploadedFile']['name'] returns only the name but not the path.
so how do i do it?
Link to comment
Share on other sites

[!--quoteo(post=356872:date=Mar 21 2006, 06:24 AM:name=eranwein)--][div class=\'quotetop\']QUOTE(eranwein @ Mar 21 2006, 06:24 AM) [snapback]356872[/snapback][/div][div class=\'quotemain\'][!--quotec--]
i need to check if an uploaded file exists.
i'm using file_exists($filename).
as i understand, the $filename should be the path and name of the uploaded file.
$_FILES['uploadedFile']['name'] returns only the name but not the path.
so how do i do it?
[/quote]

the file is uploaded to $_FILES['uploadedFile']['tmp_name']. best thing to do then is to use is_uploaded_file, such as:

[code]
if (is_uploaded_file($_FILES['uploadedFile']['tmp_name'])) {

... we got the file, use move_uploaded_file to put it in a proper home

}
else
{
  .... we not got the file
}
[/code]

hope that helps
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.