Remote test if file exists w/ fopen w/ u and p in url

From: Date: Mon, 13 May 2002 23:18:51 +0000
Subject: Remote test if file exists w/ fopen w/ u and p in url
Groups: php.general 
Request: Send a blank email to php-general+get-97441@lists.php.net to get a copy of this message
Hi! I'm trying to see if a file exists on a remote server, in a password protected area. In the fopen documentation there is the following note: /////////////////////////////////////////////// jamie.watt@murchison.com.au 02-Feb-2000 07:39 To check if a file exists using http or ftp use the following: $fp = @fopen("http://www.someurl.com/testfile.php3","r"); if ($fp) { print"The file exists!"; } else { print"The file does not exist"; } Note: The "@" in front of fopen suppresses the error output of the function. I hope this clears up some confusion. /////////////////////////////////////////////// When I use this code with a URL like: http://user:pass@reports.somedomain.com/data/i37/20020513.trn it returns "The file exists" whether it does or doesn't. If I change the domain name to one that doesn't exist, then it returns "The file does not exist", as I would expect. Using an echo of $fp, I see $fp is set to "Resource id #1" whenever the script sets $fp as TRUE. What's that mean? Seems there is a problem with having the user name and pass in the URL and using fopen. Any idea what's going on and more importantly, any way around it? Thanks for your time. I look forward to your reply. peace, -tad. http://www.mediatitan.com __________________________________________________ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com

« previous php.general (#97441) next »