I'm trying to check to see if a file that a user is pointing to exists or not, on a remote password protected secure site.
I copied this piece of code from php.net but it doesn't seem to be working for me and I was wondering if I need todo anything else to get it working or am I just burned. Also any alternatives to finding if a remote file exists or not would also be very helpful.
Copied Code:
Code: Select all
if (@fclose(@fopen('http://www.example.com', 'r'))) {
print('File exists.');
} else {
print('File does not exist.');
}Seems like it should work but not for me.
My Code:
Code: Select all
$file = 'HTTPS://user:pass@example.com/images/img.jpg';
if (@fclose(@fopen($file, 'r'))) { //remote file exist
print('File exists.');
} else {
print('File does not exist.');
}I've added php_flag allow_url_fopen on in my .htaccess file incase my server has it turned off, but no luck. Did Check the phpinfo output and it says it's on locally and master, so is there something else I'm missing?Warning: fopen(HTTPS://...@example.com/images/img.jpg): failed to open stream: No such file or directory in /home/me/www/fileexist.php on line **
Warning: fclose(): supplied argument is not a valid stream resource in /home/me/www/fileexist.php on line **
File does not exist.
PLEASE HELP!
Thanks in advance!
--Tecktron