Flash 8 FileReference 和文件完整性检查
Flash 8 FileReference API 使您可以定期检查正在传输的字节数:(
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}
如果上传,您建议使用此方法检查上传文件的完整性?
Flash 8 FileReference API gives you the possibility to check periodically for the number of bytes being transmitted:
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}
In case of upload, would you suggest to use this method to check for the integrity of the uploaded file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需监听 onComplete 事件即可检查文件何时正确上传。
如果到目前为止没有抛出任何错误事件,则该文件应该位于服务器上。
如果您不想信任 FlashPlayer 所发布文件的完整性(例如,您的服务器无法将其从 /tmp 文件夹中移动等),则可能需要采取一些措施来确保该过程已正确完成:
...除非您的应用程序非常明智,否则我会跳过此步骤,原因很简单,它可能会产生比您根本没有任何完整性检查更多的问题:)
更好:根据您发送的文件,您也许能够找到一个服务器脚本来检查文件是否正常,然后根据情况发回状态。
Just listen to the onComplete event to check whenever the file is properly uploaded.
If no error events have been thrown so far the file should be on the server.
If you don't want to trust FlashPlayer regarding the integrety of the posted file (e.g. your server failed moving it from the /tmp folder, etc. ), something likely would be necessary to make sure the procedure was finished properly :
... Unless your application is very sensible I would skip this though, just for the simple reason that it might generate more problems than if you hadn't got any integrity-check at all : )
Better: depending on the file you send you may be able to find out a server script to check if the file looks fine and just send back a status depending on that.