justinbriggs1 Posted November 23, 2008 Share Posted November 23, 2008 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 More sharing options...
Lulzim Posted November 23, 2008 Share Posted November 23, 2008 file_exists does exactly what you need Link to comment Share on other sites More sharing options...
justinbriggs1 Posted November 23, 2008 Author Share Posted November 23, 2008 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 More sharing options...
Lulzim Posted November 23, 2008 Share Posted November 23, 2008 if you want to use header to redirect to another page, you shouldn't output anything above header, so remove print "File does not exist"; Link to comment Share on other sites More sharing options...
justinbriggs1 Posted November 24, 2008 Author Share Posted November 24, 2008 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,JWThat'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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.