.on('complete', function(id, name, response) {
console.log(id);
console.log(response);
console.log(name);
$("input").attr({
type: 'hidden',
name: id
}).val(name).appendTo('form');
})
.on('deleteComplete', function(id, xhr, isError) {
console.log(name);
$('input[name=' + id + ']').remove();
});
I'm using latest FineUploader to upload images and add the image filenames as hidden fields (correct way) to post
their location to PHP for further processing.
The issue is id
is common between the two callbacks but it returns an object and I'm sure how to handle it. I just need to store/post the filename location to PHP.
The parameters for your callbacks are incorrect. If you are using the jQuery plug-in wrapper for Fine Uploader, each event handler always has an initial parameter of Event
. That is, the jQuery event object associated with the event you are handling.
Just to be clear, you code should look like this:
.on('complete', function(event, id, name, response) {
...
})
.on('deleteComplete', function(event, id, xhr, isError) {
...
});
This is one of many reasons why I have advised users to avoid using the jQuery plug-in wrapper. It makes working with Fine Uploader callbacks more confusing, and provides absolutely no benefits. In light of this, if you still want to use the jQuery plug-in wrapper for some reason, you should consider declaring your callback handlers as part of a callback
option passed as part of the initial configuration options when constructing a Fine Uploader instance.