Is there anyway to modify the queue item's message if there is an error in the back end script of uploadify.php? See mock-up below.
The first (gray) image will display completed even if there is a validation error in the back end script. This is a bit misleading. I would like it to look like second image above if possible开发者_JAVA百科. I've managed to get something close but I'm thinking it might not be the best solution, this is what I have so far:
...
'onComplete' : function( event, ID, fileObj, response, data ) {
if ( 1 != response ) {
$( '#image-upload' + ID ).addClass( 'uploadifyError' );
$( '#image-upload' + ID + ' .percentage' ).text( ' - Upload Error' );
}
}
...
Thanks for any and all help in advance!
The key was to returning FALSE with the onComplete event which allowed me to re-write the contents of the .percentage DIV.
My back end script will return 1 if everything is cool which allows onComplete to fire it's default function. If everything is not cool then a string is returned for the specific type of error. That then gets entered into the .percentage DIV.
'onComplete' : function( event, ID, fileObj, response, data ) {
if ( 1 != parseInt( response ) ) {
$( '#image-upload' + ID ).addClass( 'uploadifyError' );
$( '#image-upload' + ID + ' .percentage').text( ' - ' + response );
return false;
}
}
精彩评论