I have a plupload instance based on a custom example from the site in place, it works flawlessly, except for displaying error messages that come from the script download server (upload.php from the examples folder when loading).
Local error messages are displayed, for example, if I try to download a file type that was limited, I get the error message that I am expecting, however, the server-side messages simply do not appear.
I know that the upload.php file starts up properly, since my uploads were processed successfully, and I set the sleep function to also verify that the file is being requested. At that moment, when I just placed the lines at the top of my upload.php to help with debugging, which just sleep for 10 seconds and return an error message, this still does not work.
upload.php
sleep(10);
die('{"jsonrpc" : "2.0", "error" : {"code": 500, "message": "THIS IS AN ERROR."}, "id" : "id"}');
...(Rest of normal upload.php file)...
The javascript used is included below, any help that you guys could give would be greatly appreciated as I spend too long on this and the problem prevents me from returning to my live code.
Thank,
Alex
$(function() {
var fanart_uploader = new plupload.Uploader({
runtimes : 'html5,flash,html4',
browse_button : 'fanart_pickfiles',
container : 'fanart_container',
drop_element : 'fanart_drop',
chunk_size : '1mb',
max_file_size : '8mb',
url : '/upload.php?gameid=<?= $gameid ?>&arttype=fanart',
flash_swf_url : '/js/plupload/js/plupload.flash.swf',
silverlight_xap_url : '/js/plupload/js/plupload.silverlight.xap',
filters : [
{title : "Image files", extensions : "jpg,png"},
]
});
fanart_uploader.bind('Init', function(up, params) {
$('#fanart_runtime').html("You are using " + params.runtime);
});
$('#fanart_uploadfiles').click(function(e) {
fanart_uploader.start();
e.preventDefault();
});
fanart_uploader.init();
fanart_uploader.bind('FilesAdded', function(up, files) {
$.each(files, function(i, file) {
$('#fanart_filelist').append(
'<div style="padding: 4px; margin: 3px; border: 1px dotted #fff; border-radius: 6px; background-color: #333;" id="' + file.id + '"><img class="tick" src=\"<?= $baseurl ?>/images/common/icons/tick_16.png\" style=\"display: none; vertical-align: -2px;\" />' +
file.name + ' <em>(' + plupload.formatSize(file.size) + ')</em> <div style=\"margin: auto; margin-top: 3px; width: 200px; height: 20px; border: 1px solid #fff; border-radius: 6px; background-color: #222;\"><div class="progressbar" style=\"width: 0px; height: 16px; padding: 2px 0px; background-color: #ccc; border-radius: 6px; text-align: center;\"><b style="font-size: 16px; color: #222;"></b></div></div>' +
'</div>');
});
up.refresh();
});
fanart_uploader.bind('UploadProgress', function(up, file) {
$('#' + file.id + " b").html(file.percent + "%");
$('#' + file.id + " .progressbar").css("width", (file.percent * 2));
});
fanart_uploader.bind('Error', function(up, err) {
$('#fanart_filelist').append("<div>Error: " + err.code +
", Message: " + err.message +
(err.file ? ", File: " + err.file.name : "") +
"</div>"
);
up.refresh();
});
fanart_uploader.bind('FileUploaded', function(up, file) {
$('#' + file.id + " .tick").show();
});
});