I am definitely looking forward to this tutorial. I tried this sample code (https://developer.coronalabs.com/code/upload-binary-corona-php-script) and it works when I try uploading a image (jpg).
To add on, that code does not provide a way to send in the filename together with it. So, you will need to modify it, so that the filename is sent together with the HTTP header, so the PHP-server side knows what filename it should be.
PHP-server side :
\<?php // Used when this function in PHP does not exist function apache\_request\_headers() { $arh = array(); $rx\_http = '/\AHTTP\_/'; foreach($\_SERVER as $key =\> $val) { if( preg\_match($rx\_http, $key) ) { $arh\_key = preg\_replace($rx\_http, '', $key); $rx\_matches = array(); // do some nasty string manipulations to restore the original letter case // this should work in most cases $rx\_matches = explode('\_', $arh\_key); if( count($rx\_matches) \> 0 and strlen($arh\_key) \> 2 ) { foreach($rx\_matches as $ak\_key =\> $ak\_val) $rx\_matches[$ak\_key] = ucfirst($ak\_val); $arh\_key = implode('-', $rx\_matches); } $arh[$arh\_key] = $val; } } return( $arh ); } // Get filename from headers $headers = apache\_request\_headers(); $filenameInHeader = 'FILENAME'; $filename = $headers[$filenameInHeader] ; $pngdata = $HTTP\_RAW\_POST\_DATA; if( isset( $pngdata ) ) { $img\_file = fopen ($filename, 'wb'); fwrite ($img\_file, base64\_decode( $pngdata )); fclose ($img\_file); echo "Success."; } else { echo "Failure."; } ?\>
Corona side :
local filenameToPhp = "yourfilenamehere.jpg" local function uploadBinary ( filename, url, onComplete ) local mime = require "mime" local path = system.pathForFile( filename ) local fileHandle = io.open( path, "rb" ) if fileHandle then local params = { headers = { ["Content-Type"] = "multipart/text", ["Filename"] = filenameToPhp, }, body = mime.b64( fileHandle:read( "\*a" ) ), progress = "upload", } io.close( fileHandle ) local function networkListener ( event ) print("main networkListener phase : " , event.phase, event.isError , event.response ) if event.phase == "began" then print( "main event.bytesEstimated : " , event.bytesEstimated ) elseif event.phase == "progress" then print( "main event.bytesEstimated, event.bytesTransferred : " , event.bytesEstimated, event.bytesTransferred ) elseif event.phase == "ended" then if (onComplete) then onComplete(event); end end return true; end network.request( url, "POST", networkListener, params) end end uploadBinary ( "localFilenameToUpload.jpg", "http://www.yoursite.com/uploadFile.php" , nil )