I want to check if file exist on remote server. The problem are 2: the file is very big and no have headers.
-
What you have tries so far?Please give that code. – EHS Jun 28 '13 at 07:21
-
file_exists() ? Read about it. – Robert Jun 28 '13 at 07:28
-
I try with curl, file_exist.... very big for curl (I need to be fast because that is only check I not get it) and file_exists return false. Have in mind that we can have user and pass in the url and url can be ftp or http – user2530898 Jun 28 '13 at 07:34
3 Answers
To check the if file exists on server you should use php built in function file_exists()
However if file is larger than 2 gB there can be problems. From php.net
Because PHP's integer type is signed and many platforms use 32bit integers, some filesystem functions may return unexpected results for files which are larger than 2GB.
You can try compile php with large file support and then use fgets()
to get only few bytes to check if file exists. If it doesn't work you can use external application and shell_exec()
this application will get 2 params one is path to file and it will return 0 if file doesn't exists or 1 if it exists.
The link to program in c++ that checks if file exists you can simply modify it to print 1 or 0
Hope it'll help you.
Without code we can only guess, anyway below code may help you,
<?php
$filename='yourfilename';
$exists = file_exists($filename);
if($exists) {//checking the existance of file
$filesize= filesize ( $filename );// file size
if($filesize<$reqSize)//let $reqSize is your conditional size
{
$headers=get_headers($filename);
print_r($headers);// file headers array
}
}
?>
Reference

- 40,431
- 11
- 76
- 106
You could make a standard ftp list directory, this should give you a list of files on the server, then you could use some standard functions to "grep" your filename and if it is there then the file is on the server -- hopefully in a folder with not too many files

- 527
- 5
- 11