Jump to content

Losing Files Selected For Upload After Entering Wrong Recaptcha Code


yesvee

Recommended Posts

Hi

I have a form which collects information from a user, it also has an option to upload files. I placed a recaptcha control on the form to avoid bots. However the problem is i have many fields on the form which are lost if i give a wrong captcha.

 

I'm using hidden fields to store input values, so if user enters wrong captcha i'm restoring field values from the hidden fields, however i don't know how this can be done if the input type is file. Is it possible to store file info in the hidden field too, is yes how?

 

at the moment it is major problem if user enters wrong code after selecting some files.

 

Thanks for any input..

yesvee

Link to comment
Share on other sites

You can save the file to your server when they first post it, somewhere temporary with a unique id to reference it.  If there were errors on the form, then print out some message indicating they have uploaded that file and a hidden field to track it's ID.

 

That is pretty much the only way to handle it.  There is no way to re-populate a file input or anything similar.

 

Link to comment
Share on other sites

One possible way to make this easier for your users, is to add a AJAX call to the ReCaptcha field. In addition to the server-side checking. That way you can have the ReCaptcha tested, before you submit the rest of the form, if the user has JS enabled.

Should the test fail, then regenerate it (using the server-side code), replace it (with the JS-code), and stop the form from posting.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.