Jump to content

Archived

This topic is now archived and is closed to further replies.

eranwein

file_exists

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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.