I have a page where the user can upload an image, along with all their personal info (names, address, blabla). If they forget to fill in their name, then the form resets, and remembers everything they're previously entered - EXCEPT for the image location. I don't want the user to have to search for their image everytime they forget to fill in one of the required fields. But I can't get the upload image field to remember the POST values. I understand that <input type="file"> can't be set by most browsers as a security precaution (to avoid websites automatically grabbing user's files). Is there another way around this?
I think you're wanting something like this: $_FILES['uploadedfile']['name']=$pathandfilename; PHP: I believe that auto-populates the input box you're using.
So I permit the form to go ahead and upload the file, even if some required fields haven't been completed... then go back and get them to complete the fields they missed? I'll give it a shot. Thanks
Bugger. I tried it, and there's 2 problems. 1. $_FILES['image']['name'] only brings in the image name (e.g myimage.jpg), not the actual path to the file on the users PC. 2. It still won't populate the value for <input type="file">
Just read your post back again - how about have Javascript validate the form first? That way if anything fails validation nothing is submitted and the form stays exactly as it is for editing!
Yeah. That's what I thought (in my first post). I was hoping there was a way around it. I think I'll just have to upload the image, then send the user back to the form, and grey out the image field.
No need for that - what if the user decides not to carry on registering? What happens with the file? Just do as I suggested in my previous post - no need to upload anything until the Javascript validates the rest of the form although I'd still keep checking the variables with PHP when received just in case anyone tries to make their own HTML form bypassing the Javascript check.
You must have been editing your post as I typed mine I'm so wrapped up in PHP that I forgot about JS form validating I'm getting dumber by the day... Cheerz + REP
Thank-you very much for the rep - I believe that's my first (even with this being my 110th post and I've only posted 1 intro topic and asked 1 question... not bad lol)
possible though if you could use javascript or ajax way, probably better to use jQuery ajax file upload plugin ..