danielm / uploader

A lightweight and very configurable jQuery plugin for file uploading using ajax(a sync); includes support for queues, progress tracking and drag and drop.
https://danielmg.org/demo/java-script/uploader
MIT License
1.17k stars 385 forks source link

It'd be great if 'id' can be sent as a part of extradata #67

Closed abbasl7 closed 6 years ago

abbasl7 commented 6 years ago

While uploading the file, if 'id' can also be sent in the request along with file, it would be handy to deal with some situations where we use that as a unique identifier for each file.

dcaton commented 6 years ago

Turns out this is easy. If you specify a function for the extraData option, a single parameter is passed in which is the file id.

        extraData: function (fileid)
        {
            return {
                "fileid": fileid
            };
        },

You'll end up with a form field named "fileid" in your HTTP request that contains the id.

abbasl7 commented 6 years ago

That's smart! Thanks, @dcaton 👍