phpcodec Posted August 19, 2008 Share Posted August 19, 2008 How can i check to see whether a file exists on another server such as photobucket Link to comment https://forums.phpfreaks.com/topic/120332-solved-file-exists/ Share on other sites More sharing options...
Fadion Posted August 19, 2008 Share Posted August 19, 2008 A simple method should be using fopen() <?php $check = @fopen('http://www.site.com/remotefile.jpg', 'r'); //the @ suppresses error messages if the file is not found if($check){ echo 'File exists'; } ?> Link to comment https://forums.phpfreaks.com/topic/120332-solved-file-exists/#findComment-619952 Share on other sites More sharing options...
phpcodec Posted August 19, 2008 Author Share Posted August 19, 2008 Thanks GuiltyGear but i get this message: Warning: fopen() expects at least 2 parameters, 1 given in /mounted-storage/home63b/sub002/sc39060-WBVM/xxxxxx.net/xxxxxx/xxxxxx.php on line 15 Link to comment https://forums.phpfreaks.com/topic/120332-solved-file-exists/#findComment-619953 Share on other sites More sharing options...
trq Posted August 19, 2008 Share Posted August 19, 2008 Did you pass fopen() a second argument? Post your code. Link to comment https://forums.phpfreaks.com/topic/120332-solved-file-exists/#findComment-619959 Share on other sites More sharing options...
Fadion Posted August 19, 2008 Share Posted August 19, 2008 Probably you saw the code before i edited, as i forgot to put the 'mode' parameter. The syntax should be: fopen(string $file, string $mode) so in code: <?php fopen('path/to/the/file', 'r'); //where 'r' specifies that the access should be read only ?> Link to comment https://forums.phpfreaks.com/topic/120332-solved-file-exists/#findComment-619960 Share on other sites More sharing options...
phpcodec Posted August 19, 2008 Author Share Posted August 19, 2008 thanks that works now Link to comment https://forums.phpfreaks.com/topic/120332-solved-file-exists/#findComment-619964 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.