Where are you computing $myencodedB64md5?
Where are you setting the value for $image1?
Where are you computing $myencodedB64md5?
Where are you setting the value for $image1?
In corona sdk.
Where are you setting the value for $image1?
In corona sdk
local destDir = system.DocumentsDirectory local path = system.pathForFile( “poeta01.jpg”, destDir ) local file, errorString = io.open( path, “r” ) local myFoto ="" local originalSize=0 local codi64Size=0 local myFoto64="" local myFoto64uncoded="" local myencodedB64md5="" local myencodedJPGmd5="" if not file then print( “File error: " … errorString ) else myFoto = file:read( “*a” ) originalSize= string.len(myFoto) print (“Original Size”, originalSize) myFoto64 = mime.b64(myFoto) codi64Size = string.len( myFoto64 ) print (“Encoded 64 Size”, codi64Size) myFoto64uncoded=mime.unb64 (myFoto64) print (“and Size after Decoded”, string.len(myFoto64uncoded )) io.close( file ) print (“Saving to”,“myencoded.jpg”,” myenconded.b64") local path2 = system.pathForFile( “myencoded.jpg”, destDir ) local file2, errorString2 = io.open( path2, “w” ) if not file2 then print( "File error: " … errorString2 ) else scm = mime.unb64(myFoto64) file2:write( scm) io.close( file2 ) end – MD5 Calculation myencodedB64md5 = crypto.digest( crypto.md5, myFoto64 ) local myencodedJPGmd5 = crypto.digest( crypto.md5, myFoto64uncoded ) print ("md5 ",myencodedJPGmd5,myencodedB64md5) file = nil file2 = nil local file3, errorString3 = io.open( system.pathForFile (“myencoded.b64”, destDir),“w” ) file3:write (myFoto64) io.close( file3 ) file3 = nil end
Are you on Windows? You may need to open the file in binary mode. I also don’t understand why you’re saving all these files and them opening them and re-reading them. Why not simply open the binary JPEG image, read it in like you are, base64 encode the file, compute an MD5 hash of the original JPEG data, not the base64 version, send that to your server., base64 decode the string of base64 data, compute the MD5 on the decoded value and compare the two md5 hashes. You can simplify this a lot.
Rob
Greetings and apologies for answering so far.
I’ve organized the process just to verify that the variable encodedb64 (myFoto64) is being well calculated in the Corona SDK (And that’s it, confirmed)
The point is that all the data I give to the newtwork.request is fine, and the API SERVER receives all of them, but only bad (wrong) the variable that contains the base64 string
Regards,
Solón
Maybe try doing a:
print\_r($\_POST[]);
And comparing what’s in the $_POST associative array with what you think you’re sending.
Rob
var\_dump($\_POST);
Can also be very helpful
Hi,
In this post you can see what could be the origin of the problem and the possible solution:
Regards,
Solca