0

I am having a form submit in which the user can be able to choose multiple images( choosing one by one ) not multiple enabled in file field.

When the user chooses the image I will add an image tag for image preview and hidden file field for each of the images added.

When the validation fails in back end it just removes a file field. This removes a file field for each time when validation error occurs(any field validation). Anything better can be done for this?

Sandeep Garg
  • 1,234
  • 1
  • 13
  • 29
Aarthi
  • 1,201
  • 8
  • 27

1 Answers1

0

Why don't you show preview before image file being uploaded, follow the link

note: will not work in IE8(fileReader is supported from IE10).

NRaghavendra
  • 126
  • 2
  • 7
  • I have added preview and I need to allow the user to upload many images, When the form gets submitted using remotipart(while validation error occurs) it deletes the added hidden field – Aarthi Jun 22 '18 at 10:35
  • try using class variable so that it stores values and you can access in view although validations fails. – NRaghavendra Jun 22 '18 at 10:43