Hi Rob, After reading your reply and a bit more trial and error, I have solved the problem. I can now do a -e "$pathname/$filename" test (and other file tests) on my files. Thank you for your help.
To elaborate, I had to set 2 path variables. One to define the absolute path of the uploaded image files on the web server, and the other to define the relative path (from the perl program) to the image files. I then do an existence test on an image file using the absolute path, and if it exists, display the file with <img src= ... > using the relative path. It now works a treat! Whether that is the 'correct' way of doing it I am not sure, but it seems to be the only combination I have tried that works. Cheers, Mike. ----- Original Message ----- From: "Hanson, Rob" <[EMAIL PROTECTED]> To: "'Mike'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Saturday, September 06, 2003 11:23 AM Subject: RE: File existence under Microsoft IIS > The -e test does work on MS-Win, not sure what the problem might be. One > thing I can think of is that you should avoid relative paths because IIS > will set the current directory to C: (if I remember correctly). > > These work for me on Win2K: > > print -e 'C:/Perl'; > print -e 'C:/Perl/bin/perl.exe'; > print -e 'C:/Program Files'; > print -e 'C:/Program Files/WinZip'; > > Rob > > > -----Original Message----- > From: Mike [mailto:[EMAIL PROTECTED] > Sent: Friday, September 05, 2003 9:13 PM > To: [EMAIL PROTECTED] > Subject: File existence under Microsoft IIS > > > Hello, > > I have been trying a number of ways to determine whether a file exists in a > particular directory, but to no avail. > The perl books I have (and many web sites/forums I have checked) mention the > '-e' test on a filehandle or filename, but it returns false (the file does > not exist) even if it does. I have used code such as: > > if (-e 'filepath/filename') { # using absolute naming with full pathname > etc. > # display the file (image) in the HTML output > } > > and > > if (-e "$filepath/$filename") { # using variables as the path and name > information > # display the file > } > > and > > if (open(TMP, "<$filepath/$filename")) { # to test whether the file can be > opened > # I would expect a false (or undef) if the file did not exist > # display the file > } > > I commented out the if statement (and closing brace '}' ), and manually set > the file to be displayed, and it worked. That was to check that the path & > filename were correct. I would like to be able to display the image if it > exists, or display another 'image does not exist' image if the image file > does not exist. > > I have even tried the 'use File::stat' module methods. > > I do not get any fatal errors - the rest of the HTML output works fine - > just no image displayed even though I know the filepath & name do indeed > exist. Am I missing something obvious? The only thing I can think of at > this stage is that the -e test (and related file tests) are for Unix-based > servers and I am running from a MS IIS-based server. But if that were the > case, wouldn't the server spit out an error that it didn't understand -e? > Are there similar (but different) file tests for IIS? > > Thanks in advance, > Mike. > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
