innostudio / fileuploader

Beautiful and powerful HTML file uploading tool. A jQuery, PHP and Node.js plugin that transforms the standard input into a revolutionary and fancy field on your page.
141 stars 25 forks source link

beforeSend and remove at uploading stage #7

Closed s0By closed 7 years ago

s0By commented 7 years ago
// Callback fired before uploading a file
// by returning false, you can prevent the upload
beforeSend: function(item, listEl, parentEl, newInputEl, inputEl) {
    // example:
    // here you can extend the uploading data
    item.upload.data.new_data_attribute = 'nice';

    return true;
}

The example that is provided in documentation doesn't seem to work. It's not even assigning anything to data. If you'll do item.upload.new_data_attribute = 'nice'; it will be there at uploading stage but won't be transferred to uploaded file. As a temporary workaround I'm currently assigning attributes in onSuccess stage which is not an ideal solution.

Also I have a problem with onRemove. When the file is already uploaded and I try to remove it - everything is ok. If I try to remove the file while it's still being uploaded I get Illegal invocation error and then the whole onRemove stops working, even on uploaded files.

screen shot 2017-05-23 at 10 44 23
innostudio commented 7 years ago

@s0By i've tested with https://innostudio.de/fileuploader/documentation/examples/default-upload/

What example are you using? Try to use the unminified script and write the exact line of the error

s0By commented 7 years ago

For the Illegal invocation part, I think that was my issue. The problem was with ajax request that is being generated. It tried to pass some data, that didn't exist during upload stage, so I was getting undefined data.

In my use case I'm renaming the file during upload so I don't know the new name of the file until upload is complete. So for my case I had to turn onRemove off until the file is uploaded, only then I'm able to successfully remove a file.

But beforeSend question remains open.

innostudio commented 7 years ago

@s0By I can take a look, but it's oddly that it works in all examples and not working for you. Write me an Email with your Teamviewer authentication details.

innostudio commented 7 years ago

No answer. Closed.

s0By commented 7 years ago

Sorry. Forgot to write. Since I'm manipulating the file on the serverside and changing some properties of it there, beforeSend was pretty pointless for me, so even tho it didn't work for me (even if I needed it) I managed to do things with regular ajax request.

Sam-Butler commented 7 years ago

How did you get back the response from the AJAX request?