BarneyJoe Posted December 6, 2006 Share Posted December 6, 2006 Just as I thought everything was looking just as it should with my add record / upload image page with all it's validation, I've just spotted an odd one - nothing crucial, just a bit odd looking.I basically have this code to check if a file has already been uploaded :[code]if (file_exists("Photos/" . $_FILES["uploadFile"]["name"])) { $ValidationFailed = true; $FTGvalid_file_errmsg = "This file has already been uploaded. If you are sure it's a new photo please rename it before uploading to the library."; $ErrorList .= $FTGvalid_file_errmsg . '<br/>'; } [/code]Which works just as it should if a file already uploaded is selected.However, if no file is selected, I'm still getting the error message.This isn't major, as a file does have to be uploaded - indeed there is also a check on file type, which flags any blanks anyway - but it's just a bit odd that the 'File is already uploaded' is coming up when no file is selected?Can this be tweaked at all? I also tried changing the Null column back in mySQL to see if that was an issue, but it didn't seem to be. Quote Link to comment Share on other sites More sharing options...
noobstar Posted December 6, 2006 Share Posted December 6, 2006 Not sure if this helps but have you tried putting in a else statement that when there is no file selected it would say something like "No file selected"? Quote Link to comment Share on other sites More sharing options...
BarneyJoe Posted December 6, 2006 Author Share Posted December 6, 2006 Cheers.Turns out I needed to change :[code]if (file_exists("Photos/" . $_FILES["uploadFile"]["name"]))[/code]to :[code]if (!empty($_FILES['uploadFile']['name']) && file_exists("Photos/" . $_FILES["uploadFile"]["name"]) && is_file('Photos/' . $_FILES['uploadFile']['name']))[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.