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
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.