Jump to content

Verify a file exists


justinbriggs1

Recommended Posts

I seem to be having trouble figuring out a way to search a web server directory to verify that a file exists. For example:1. A user inputs a file name into an input box that he wants to associate with a database record.2. PHP makes sure the file exists before processing the request.Any ideas? Thanks,JW

Link to comment
Share on other sites

file_exists does exactly what you need :)
Oh yeah...thanks maybe you could help me figure out whats wrong with this code:if(!file_exists($folder.$bonus_file))//print "File does not exist";header('Location:http://www.foo.com/bonusadd.php?ERROR=nofile');It seems to work fine when I test it with "print", but won't direct when I try to use the header. Any ideas?THanks,JW
Link to comment
Share on other sites

Oh yeah...thanks maybe you could help me figure out whats wrong with this code:if(!file_exists($folder.$bonus_file))//print "File does not exist";header('Location:http://www.foo.com/bonusadd.php?ERROR=nofile');It seems to work fine when I test it with "print", but won't direct when I try to use the header. Any ideas?THanks,JW
That's commented out, I just left it to show that when I swapped the two commands, it functions fine. If I only have the header line, the command is skipped.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...