Sunday, January 23, 2011

PHP Check Remote File

In this tutorial we we will check whether a file exist or not remotely using PHP
$filepath = "http://img.metblogs.com/lahore/files/2008/12/jinnah.jpg";
$isFileExists = file_get_contents($filepath,null,null,-1,1) ? true : false ;

if($isFileExists){
     echo "File Exists!";
}else{
     echo "File Does Not Exists";
}
what we do here is we use simple file_get_contents function just limiting its offset to -1 and maxlen or the amount of data to be read to 1 and check if the read is successful or not.

0 comments:

Post a Comment

 

Blog Info

A Pakistani Website by Originative Systems

Total Pageviews

Tutorial Jinni Copyright © 2015 WoodMag is Modified by Originative Systems