2

I have a form in which i user jQuery file uploader

My form contains lot of other fields other than the profile picture the user uploads. I want to upload the profile picture by sending only profile picture parameters alone with ajax and show user the progress bar with upload status.

Here is the coffee script i use for this.

$('#user_edit_form').fileupload
    url: '/users/files_upload'
    type: 'POST'
    add: (e, data)->
      # e.target gives the form.
      types = /(\.|\/)(gif|jpe?g|png)$/i
      file = data.files[0]
      # file type verification.
      if types.test(file.type) || types.test(file.name)
        data.progress_div = $('#' + data.fileInput.attr('id')).closest('.control-group').find('.upload_progress')
        data.progress_div.show()
        data.submit()
      else
        alert('The file you selected is not a gif, jpeg or png image file')
    progress: (e, data)->
      progress = parseInt(data.loaded / data.total * 100, 10)
      data.progress_div.find('.bar').css('width', progress + '%')

this code sends all the fields in the form. I need help to send only the file fields as params. (i.e., nothing but serializing the file filed alone)

Thanks

aBadAssCowboy
  • 2,440
  • 2
  • 23
  • 38
  • Did you ever solve this issue? I'm having this very same issue when I use the plugin in VMC, yet without VMC implementation this doesn't happen. – kaarto Apr 27 '19 at 04:53

0 Answers0