Response Handling
Custom response parsing with the responseParser option. Transform server responses into a consistent format.
Drag & drop files here
Server responses will appear here...
var uploader = new MultipleUpload(el, {
uploadUrl: '/api/upload',
responseParser: function(xhr) {
// Parse custom server response format
try {
var data = JSON.parse(xhr.responseText);
return {
success: data.status === 'ok',
fileId: data.id,
url: data.downloadUrl,
message: data.message || ''
};
} catch (e) {
return { success: false, message: 'Invalid server response' };
}
},
onTaskComplete: function(task) {
console.log('File ID:', task.response.fileId);
console.log('Download URL:', task.response.url);
}
});
Your API's shape, not the component's
responseParser pulls the fields you need out of whatever your endpoint returns, so a server already speaking its own JSON dialect does not have to change to match the uploader. Extract the URL, the id, the storage key — whatever the rest of your application needs.
Errors are the half that gets skipped
A failed upload usually carries a useful message in the body, and without a parser the user sees a bare status code. Pulling your API's error text through here is the difference between “HTTP 422” and “that document type is not accepted for this case”.