3
我一直在搞SWF上传,我真的很喜欢它。我能够非常轻松地将它应用于我的文件上传类,而且几乎没有问题。然而,我遇到的问题是我需要能够将错误发送给上传者,以便用户知道他们的文件是否由于诸如太大或格式错误等原因而未能完全上传等等。我阅读了SWF Upload的作者提供的PHP示例脚本,但我无法弄清楚如何将错误传回给它。这是错误处理功能:SWF上传:返回错误
/* 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功能。
HttpResponse :: setCache(true); HttpResponse :: status(200); HttpResponse :: setContentType('text/html'); HttpResponse :: setData('这是错误文本'); HttpResponse :: send(); 如果我尝试这样的事情,SWF上传返回500错误,但该文件仍然上传。 – Throttlehead
只需在标题调用之后'echo'你的消息就好了(不要让你的'SWF上传器'方便,但我认为至少是错误函数的作用)。 – Wrikken
我已经想通了。我正在使用他们在其网站上提供的处理程序脚本,并在其中找到了uploadSuccess处理函数。它只是输出“完成”。通过将它传递给serverData变量,它可以完美地工作。谢谢! – Throttlehead