0

I am trying to submit form which have images field . problem is when i submit form with data image couldn't submit with form which is in jquery code

I tried to submit images by putting input images field in form .is working

<form action="/product" method ="post" enctype="multipart/form-data">
<div class="input-container active">
<label class="rl-label required">Upload Pictures (Max 5)</label>
<!-- UPLOAD FILE -->
<div class="imagesupload">
<div class="pic" >
</div>
</div>
</div>
</form>
<script>

(function ($) {
  $(document).ready(function () {

    uploadImage();

 function uploadImage() {
      var button = $('.imagesupload .pic')
      var uploader = $('<input  type="file" accept="image/*" name="productImages[]" multiple/>')
      var images = $('.imagesupload')

      button.on('click', function () {
        uploader.click()
      })

      uploader.on('change', function () {
          var reader = new FileReader()
          reader.onload = function(event) {
            images.prepend('<div class="img" style="background-image: url(\'' + event.target.result + '\');" rel="'+ event.target.result  +'"><span>REMOVE</span></div>')
          }
          reader.readAsDataURL(uploader[0].files[0])

       })

      images.on('click', '.img', function () {
        $(this).remove()
      })


    }  

  })
})(jQuery)


</script>

I want to submit this image data

Bilal Arshad
  • 531
  • 3
  • 11
  • 33

0 Answers0