gpt4 book ai didi

php - SWF 上传 : Returning errors

转载 作者:搜寻专家 更新时间:2023-10-31 22:15:37 24 4
gpt4 key购买 nike

我一直在研究 SWF 上传,我真的很喜欢它。我能够非常轻松地将它应用到我的文件上传类中,几乎没有问题。然而,我遇到的问题是,我需要能够将错误发回给上传者,以便用户知道他们的文件是否实际上由于太大或格式错误等问题而未完全上传等。我通读了 SWF 上传作者提供的 PHP 示例脚本,但我不知道如何将错误传回给它。这是错误处理函数:

/* Handles the error output.  This function was written for SWFUpload for Flash Player 8 which
cannot return data to the server, so it just returns a 500 error. For Flash Player 9 you will
want to change this to return the server data you want to indicate an error and then use SWFUpload's
uploadSuccess to check the server_data for your error indicator. */

function HandleError($message) {
header("HTTP/1.1 500 Internal Server Error");
echo $message;
}

因此 uploadSuccess 函数期待来自服务器的响应。我将如何使用“header()”对上述响应进行编码和发送?

如果我使用这个:

header("HTTP/1.1 200 Uploaded File was Successful");

SWF 上传返回成功,但该消息并未传递到 uploadSuccess 函数。

最佳答案

我也在寻找一种方法来显示来自服务器的错误消息。根据上面的评论,我能够通过将 handlers.js 中的 uploadSuccess() 函数更新为:

if (serverData != null && serverData != "ok"){
progress.setError();
progress.setStatus(serverData);
} else {
progress.setStatus("Complete.");
}

意思是,如果响应不是“ok”,它将显示为错误。这感觉很hacky。我宁愿能够从服务器发送非 200 响应并让它显示错误消息,但据我所知这是不可能的。此外,我设置它的方式不适用于不是错误的自定义消息。

关于php - SWF 上传 : Returning errors,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6902886/

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