gpt4 book ai didi

jquery 插件 'uploadify' - 从上传脚本返回响应的方法?

转载 作者:行者123 更新时间:2023-12-03 23:02:06 25 4
gpt4 key购买 nike

我的标题代码:

$(document).ready(function() {
$('#sampleFile').uploadify({
'uploader': 'include/uploadify/uploadify.swf',
'script': 'add_list.php',
'scriptData': {'mode': 'upload'},
'fileDataName': 'sampleFile',
'folder': '/work/avais/bizlists/lists',
'cancelImg': 'include/uploadify/cancel.png',
'queueID': 'sampleQueue'
});
});

据我所知,我在“add_list.php”文件中所能做的就是通过将文件移动到最终目录来完成上传过程;我认为没有任何方法可以“返回某些内容”,比如错误,对吗?

如果我也可以使用此文件来禁止某些字符或在出现某种问题时返回错误,那就太好了,但我认为不存在?

我想我可以去掉任何坏字符,但是知道我是否可以以某种方式返回响应会很有用吗?

最佳答案

您可以向上传脚本添加一些事件处理程序,以检查操作是否完整以及是否有错误

$('#sampleFile').uploadify({
'uploader': 'include/uploadify/uploadify.swf',
'script': 'add_list.php',
'scriptData': {'mode': 'upload'},
'fileDataName': 'sampleFile',
'folder': '/work/avais/bizlists/lists',
'cancelImg': 'include/uploadify/cancel.png',
'queueID': 'sampleQueue'

onComplete: function (event, queueID, fileObj, response, data) {
// A function that triggers when a file upload has completed. The default
// function removes the file queue item from the upload queue. The
// default function will not trigger if the value of your custom
// function returns false.
// Parameters
// event: The event object.
// queueID: The unique identifier of the file that was completed.
// fileObj: An object containing details about the file that was selected.
// response: The data sent back from the server.
// data: Details about the file queue.
},

onError: function (event, queueID, fileObj, errorObj) {
// A function that triggers when an error occurs during the upload process.
// The default event handler attaches an error message to the queue item
// returning the error and changes it's queue item container to red.
// Parameters
// event: The event object.
// queueID: The unique identifier of the file that was errored.
// fileObj: An object containing details about the file that was selected.
// errorObj: An object containing details about the error returned.
}

});

因此,由于 onComplete 函数将从服务器端脚本发回响应,因此您可以将响应返回给客户端,然后在事件处理程序中解析该响应。

检查Uploadify documentation了解更多详情

希望对你有帮助

关于jquery 插件 'uploadify' - 从上传脚本返回响应的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4065477/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com