Send image to server with php

I am trying this to send a picture to my web server but it doesn´t work:

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"},  
 body = mime.b64( fileHandle:read( "\*a" ) ),  
 }  
 io.close( fileHandle )  
   
 local function networkListener ( event )  
 -- Note: event.isError and event.response can tell   
 -- your onComplete function how it went.  
 if (onComplete) then  
 onComplete(event);  
 end  
 return true;  
 end  
  
 network.request( url, "POST", networkListener, params)  
 end  
   
end  
   
-- uploadBinary ( filenameToUpload, postToUrl [, onComplete])  
   
uploadBinary ( "myScreenshot.png", "http://mywebpage.com/receiveBinary.php")  

The php-file looks like this:

<?php
        # This script receives a binary file uploaded from a Corona         # app.  If you are uploading something other than a PNG,         # you will want to change that here:         $filename = "myFile-" . time() . ".png";           $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.";                 } ?\> I get an error message saying: main.lua:4: unexpected symbol near '{' Anybody who can help me with this? [import]uid: 5717 topic\_id: 16613 reply\_id: 316613[/import]

On the first line you have a “{” at the end, this isn’t needed. [import]uid: 5833 topic_id: 16613 reply_id: 62054[/import]

Thanks, no errors anymore but the file doesn´t show up on my server. [import]uid: 5717 topic_id: 16613 reply_id: 62056[/import]

Ah well that one I’m not sure about, could be any number of things such as an error in your upload code or things like permissions on the server. [import]uid: 5833 topic_id: 16613 reply_id: 62060[/import]

Do you know some free webhotell where I can test this script? [import]uid: 5717 topic_id: 16613 reply_id: 62061[/import]

Not sure of any free stuff, but there is plenty of cheap stuff out there. [import]uid: 5833 topic_id: 16613 reply_id: 62082[/import]