dadamssg Posted July 21, 2009 Share Posted July 21, 2009 I want to just do a search to see if a particular file is in a directory. Which function should i use for this? fopen()? I just want it to return false if the file doesn't exist or true if it does so i can write an if statement around it. Thank YOU Link to comment https://forums.phpfreaks.com/topic/166796-solved-best-way-to-look-for-a-file-in-a-directory/ Share on other sites More sharing options...
rhodesa Posted July 21, 2009 Share Posted July 21, 2009 http://php.net/is_file http://php.net/file_exists http://php.net/realpath Link to comment https://forums.phpfreaks.com/topic/166796-solved-best-way-to-look-for-a-file-in-a-directory/#findComment-879522 Share on other sites More sharing options...
dadamssg Posted July 21, 2009 Author Share Posted July 21, 2009 thanks, i have another question. If a write a php script to upload an image to a directory and the image already exists in that directory(has the same name) will it automatically overwrite it? Link to comment https://forums.phpfreaks.com/topic/166796-solved-best-way-to-look-for-a-file-in-a-directory/#findComment-879529 Share on other sites More sharing options...
rhodesa Posted July 21, 2009 Share Posted July 21, 2009 well...when you upload a file, it get's put in a temporary folder with a unique name...to save the file you need to use http://us3.php.net/move_uploaded_file which, if the file you are moving it to already exists, will overwrite that file Link to comment https://forums.phpfreaks.com/topic/166796-solved-best-way-to-look-for-a-file-in-a-directory/#findComment-879534 Share on other sites More sharing options...
dadamssg Posted July 21, 2009 Author Share Posted July 21, 2009 awesome thank you Link to comment https://forums.phpfreaks.com/topic/166796-solved-best-way-to-look-for-a-file-in-a-directory/#findComment-879538 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.