iPhone 文件上传
我正在构建一个本机 iPhone 应用程序,其中具有文件上传功能。我需要验证并确认文件是否已完全上传。我怎样才能实现这个目标?我的服务器端脚本是用 PHP 构建的,用于接受文件数据并在服务器上写入/创建文件。
所以我正在尝试做两件事: 1.计算来自iPhone的文件的校验和并将其发布到PHP脚本 2. PHP 脚本在服务器上创建文件后,重新计算校验和并将其与发布的值进行比较。
我的查询在这里: 我使用 MD5 来计算校验和,但 Objective C 和 PHP 脚本返回的值不同?
在 iPhone 上计算校验和的最佳方法是什么?可以在服务器端进行匹配。
请建议。谢谢
I am building a native iPhone application where I have the File Upload functionality. I need to verify and confirm if the file was uploaded completely. How can I achieve this? My server side script to accept the file data and write/create the file on the server is built in PHP.
So I am trying to do 2 things:
1. Calculate the checksum of the file from iPhone and post it to PHP script
2. Once the PHP script creates the file on the server, recalculate the checksum and compare it with the posted value.
My Query here:
I am using MD5 to calculate the checksum but the values returned by objective c and PHP script are different?
Which is the best way I can calculate the checksum on iPhone? which can be matched on the server side.
Please suggest. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我总是用于 md5sums 的代码片段:
在此处查看 ASIFormDataRequest http://allseeing-i .com/ASIHTTPRequest/如何使用
对于此类操作来说,它是一个非常有用的包装器。在我的用于上传文件和 md5sum 的代码片段下方:
确保检查服务器端是否一切正常(md5sums 匹配并且文件上传正常)。然后使用
[request responseString]
评估服务器的响应并采取适当的操作。Here's a code snippet I always use for md5sums:
Check out ASIFormDataRequest here http://allseeing-i.com/ASIHTTPRequest/How-to-use
It's a very helpful wrapper for this kind of operation. Below my codesnippet for uploading a file and md5sum:
Make sure that you check serverside if everything is ok (md5sums match and file was uploaded ok). Then evaluate your server's response with
[request responseString]
and take appropriate action.