Clay Trainor Posted March 15, 2007 Share Posted March 15, 2007 Hi, i had a previous post about this topic, but the title wasnt appropriately named so someone who might know the solution, could've overlooked it, so after a couple days of no success, i thought i'd make this topic. I have been trying to detect whether a picture exists or not, using either is_file or file_exists, and I always get a FALSE readback, saying it doesnt exist, even though it does. this is my code <?php $filepath = "http://www.mysite.com/pictures/tvshowdvd/Lost.jpg"; if (is_file($filepath)) { $img = $filepath; } else { $img = "http://www.digitaltechnews.com/photos/uncategorized/netflix.gif"; } ?> im pretty sure the code is right, i've been checking it over for days, but i just cant seem to get the functions to work. any help is much appreciated, thank you. Link to comment https://forums.phpfreaks.com/topic/42870-is_file-and-file_exists-cant-get-either-to-work-have-tried-for-2-days/ Share on other sites More sharing options...
genericnumber1 Posted March 15, 2007 Share Posted March 15, 2007 I'm under the impression they only work for relative/absolute paths, not http. Link to comment https://forums.phpfreaks.com/topic/42870-is_file-and-file_exists-cant-get-either-to-work-have-tried-for-2-days/#findComment-208192 Share on other sites More sharing options...
per1os Posted March 15, 2007 Share Posted March 15, 2007 is_file only works on the relative path. IE: /www/home/username/images/file.jpg has to be used and cannot reference the virtual (http://) location. Link to comment https://forums.phpfreaks.com/topic/42870-is_file-and-file_exists-cant-get-either-to-work-have-tried-for-2-days/#findComment-208212 Share on other sites More sharing options...
Barand Posted March 15, 2007 Share Posted March 15, 2007 PHP manual - is_file() As of PHP 5.0.0 this function can also be used with some URL wrappers. Link to comment https://forums.phpfreaks.com/topic/42870-is_file-and-file_exists-cant-get-either-to-work-have-tried-for-2-days/#findComment-208225 Share on other sites More sharing options...
per1os Posted March 15, 2007 Share Posted March 15, 2007 The question is does he have PHP 5? =) I bet he has PHP 4.x Link to comment https://forums.phpfreaks.com/topic/42870-is_file-and-file_exists-cant-get-either-to-work-have-tried-for-2-days/#findComment-208227 Share on other sites More sharing options...
Clay Trainor Posted March 15, 2007 Author Share Posted March 15, 2007 The question is does he have PHP 5? =) I bet he has PHP 4.x hmm, this is possible i should look into that. thanks Link to comment https://forums.phpfreaks.com/topic/42870-is_file-and-file_exists-cant-get-either-to-work-have-tried-for-2-days/#findComment-208230 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.