Skip to content

Reuse File Input for a second upload #86

@stefanocdn

Description

@stefanocdn

I am trying to upload 2 different versions of the same file to AWS S3 from a single form: large and thumbnail.

The code for the upload is the following. The upload works fine and in the done callback I would like to start the second upload.

fileInput.fileupload({
        fileInput:       fileInput,
        url:             form.data('url'),
        type:            'POST',
        autoUpload:       true,
        formData:         form.data('form-data'),
        paramName:        'file', // S3 does not like nested name fields i.e. name="user[avatar_url]"
        dataType:         'XML',  // S3 returns XML if success_action_status is set to 201
        replaceFileInput: false,
        disableImageResize: false,
        imageMaxWidth: 800,
        imageMaxHeight: 800,
        imageCrop: true,

        done: function(e, data) {
          console.log('DONE');

          // HERE I WOULD LIKE TO MAKE A SECOND UPLOAD
          startThumbnailUpload();
        },
      });

The code for the startThumbnailUpload() method would be exactly the same except for the width and height:

function startThumbnailUpload(){
  fileInput.fileupload({
        fileInput:       fileInput,
        url:             form.data('url'),
        type:            'POST',
        autoUpload:       true,
        formData:         form.data('form-data'),
        paramName:        'file', // S3 does not like nested name fields i.e. name="user[avatar_url]"
        dataType:         'XML',  // S3 returns XML if success_action_status is set to 201
        replaceFileInput: false,
        disableImageResize: false,
        imageMaxWidth: 200,
        imageMaxHeight: 200,
        imageCrop: true,

        done: function(e, data) {
          console.log('DONE');
        },
   });
}

The second fileInput.fileupload never gets executed. Is there a way to achieve that kind of double upload with the same file reusing the same fileinput?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions