Jump to content


Photo

file_exists


  • Please log in to reply
2 replies to this topic

#1 eranwein

eranwein
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 21 March 2006 - 06:24 AM

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?

#2 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 21 March 2006 - 08:39 AM

[!--quoteo(post=356872:date=Mar 21 2006, 06:24 AM:name=eranwein)--][div class=\'quotetop\']QUOTE(eranwein @ Mar 21 2006, 06:24 AM) View Post[/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:

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
}

hope that helps
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#3 eranwein

eranwein
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 21 March 2006 - 12:03 PM

thanks a lot




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users