ShootingBlanks Posted May 28, 2008 Share Posted May 28, 2008 Hello. I am building a program that uses the "move_uploaded_file()" function to upload files. $file_name is the variable I'm using for the file's full name (with extension, but without a path - so the file "/folder/file.doc" would have a $file_name value of "file.doc")... I just want to know how to check and make sure that, before uploading, a file with the same $file_name does not already exist on the server (so that the new file won't overwrite the old one)?... Thanks!... Quote Link to comment Share on other sites More sharing options...
gizmola Posted May 28, 2008 Share Posted May 28, 2008 file_exists function provides this for you. $filename = '/path/to/foo.txt'; if (file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } ?> Quote Link to comment Share on other sites More sharing options...
ShootingBlanks Posted May 28, 2008 Author Share Posted May 28, 2008 Perfect - thanks!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.