Jump to content


Photo

Losing Files Selected For Upload After Entering Wrong Recaptcha Code

recaptcha

  • Please log in to reply
4 replies to this topic

#1 yesvee

yesvee

    Newbie

  • New Members
  • Pip
  • 8 posts

Posted 08 December 2012 - 12:14 PM

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

#2 berridgeab

berridgeab

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationBirmingham, United Kingdom

Posted 08 December 2012 - 01:47 PM

No, you lose control of a file after it has been posted. I think this is for security reasons,

#3 yesvee

yesvee

    Newbie

  • New Members
  • Pip
  • 8 posts

Posted 08 December 2012 - 01:56 PM

do i have any options other than showing a warning message to user to upload the files again...

#4 kicken

kicken

    Wiser? Not exactly.

  • Gurus
  • 2,709 posts
  • LocationBonita, FL

Posted 08 December 2012 - 05:18 PM

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.

Recycle your old CD's, don't trash them!
Did I help you out?  Feeling generous? I accept tips via Paypal or Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7

#5 Christian F.

Christian F.

    Advanced Member

  • Staff Alumni
  • 3,106 posts
  • LocationNorway

Posted 09 December 2012 - 01:02 AM

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.
Keeping it simple.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com