0

如果uploadify.php 的后端脚本出错,是否有办法修改队列项的消息?请参阅下面的模型。

预上传

队列项目上的自定义错误

即使后端脚本中存在验证错误,第一张(灰色)图像也会显示完成。这有点误导。如果可能的话,我希望它看起来像上面的第二张图片。我已经设法接近了一些东西,但我认为这可能不是最好的解决方案,这就是我到目前为止所拥有的:

...
'onComplete' : function( event, ID, fileObj, response, data ) {

if ( 1 != response ) {

$( '#image-upload' + ID ).addClass( 'uploadifyError' );
$( '#image-upload' + ID + ' .percentage' ).text( ' - Upload Error' );

}

}
...

感谢您提前提供的所有帮助!

4

1 回答 1

0

关键是使用 onComplete 事件返回 FALSE,这允许我重写 .percentage DIV 的内容。

如果一切正常,我的后端脚本将返回 1,这允许 onComplete 触发它的默认功能。如果一切都不是很酷,则为特定类型的错误返回一个字符串。然后将其输入 .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;

                    }               
                }
于 2011-07-12T17:38:27.667 回答