Uploading Photo from iPad to Server

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
pkmittal
Posts: 111
Joined: Thu Feb 08, 2007 11:27 am
Contact:

Uploading Photo from iPad to Server

Post by pkmittal » Wed Sep 19, 2012 4:48 pm

Hello, I have taken thumnail from the video.. and that thumnail is shown in image field "samplepic" Now I would like to send this thumnail image to server...

I am using the following code

Code: Select all

on mouseUp  
   put "&bindata=" & base64Encode (img "samplepic") & "&name=imageName" into tpic
   post tpic to url "http://xyz.com/upload.php"
   answer "Congrats! You have uploaded a pic!"
end mouseUp

Code: Select all

<?php
    $filename    =    $_REQUEST['name'];
    $binddata    =    $_REQUEST['bindata'];
       
    if ( $binddata === NULL) {
        echo "missing parameter.";
    }
    else {
        $img_data = base64_decode( $binddata );
        $name = $filename === NULL ? "anonymous\n" : $filename ."\n";
        $name = strip_tags($name);
        $img_size = strlen($img_data);
        $img_filename    =    '../media/videos/'.$filename.'.jpg';
        unlink($img_filename);
        $img_file = fopen($img_filename, "w") or die("can't open file");
        fwrite($img_file, $img_data);
        fclose($img_file);
        echo "$img_size bytes uploaded.";
    }

?>
The code is able to upload the image on the server and also able to return the correct number of bytes... but when i download the image from the server then the image is black.. and not the right thumnail which was shown in the image field...

Can any one tell me what changes I need to do following.. I added the line below but it did not work..

Code: Select all

export image "samplepic" to myimage as jpeg  and then 
 put "&bindata=" & base64Encode ( myimage) & "&name=imageName" into tpic
Please help..

Thanks
Cheers
Pradeep

Post Reply