0

I want to implement a register form with some heavy fields like images fields (to upload).

When not using AJAX, the entire form is sent to the server, including the images. That can be very time consuming, and if the form is invalid, the user is forced to upload the form again. This is not user friendly.

So, I think AJAX can be a solution. But how could be the best way to do it? The images should be uploaded once, and it should be needed to upload them again if they are invalid (size exceeded, incorrect format, …).

Would it be worth to implement it in a unobstrusive way? (should everything work when javascript is disabled?)

David Morales
  • 17,816
  • 12
  • 77
  • 105

1 Answers1

1

Instead of using AJAX, and to avoid image re-uploading when the form is invalid, you can use Carrierwave that has a functionality to avoid file re-upload in this case. See "Making uploads work across form redisplays" in the README.

Florent2
  • 3,463
  • 3
  • 28
  • 38
  • What do you think of Paperclip as opposed to Carrierwave? Are they the same tool? https://github.com/thoughtbot/paperclip – David Morales Feb 10 '12 at 07:20
  • I've been involved in projects using Paperclip or Carrierwave but always in a quite basic way, so unfortunately sorry I can't give you a good feedback about their differences. But yes they both support the same general feature, file uploads. See this [SO answer](http://stackoverflow.com/a/7419851/117704) for more info. – Florent2 Feb 10 '12 at 21:38
  • Carrierwave is an impressive gem, I recommend it as it has a cache functionality to remember the image you have just uploaded when the form is invalid and the page needs to be reloaded, solving my problem. – David Morales Feb 17 '12 at 11:00