Page 1 of 1

Post an Image

Posted: Wed Jul 20, 2011 5:06 pm
by Kaubs
I've been reading the iOS notes as I've been trying to formulate how I'm going to post an image to a php script. I have had success in posting text to a url in a variable and figured that I could do the same with a picture. This didn't seem to work.
on mouseUp
put the imagedata of image "bob" into thebinarydata
put image "bob" into binarydata
post thebinarydata to url "##a url commented out"
send "swipeRight" to me in 0 seconds
end mouseUp
The problem that I've found with the above is that it DOES post and the server gets the data however when its converted it just turns into a corrupted image that cannot be opened with a filesize of 0bytes.

I then started looking into the liburl method which seemed to work for some users...however...in my reading of the iOS notes iOS doesn't support this at this time. I of course attempted it anyways and it didn't post anything. Am I correct in that liburl cannot be used to send data on the iOS or is my thinking wrong?

Thanks everyone!

Re: Post an Image

Posted: Wed Jul 20, 2011 5:43 pm
by Kaubs
Here is another thought....when you take a pic with the camera and save to the camera roll on the iphone itself it is saved as a JPEG....I just got a note of png response on a test send to the server.....does livecode import the images you take as a png and not a JPEG? That's way far fetched but...it would make sense if the server is trying to convert binary data to a JPEG and the image is really a PNG it would corrupt....

Re: Post an Image

Posted: Wed Jul 20, 2011 9:47 pm
by Kaubs
Just tried

Code: Select all

   put image test into binarydata
   put base64encode (binarydata) into mydata
   post mydata to url "http://hipster.tometasoft.com/test.php"
   answer the result
Seems to send but still having issues. Both methods listed do "send" data...just not sure if its the correct method.

Re: Post an Image

Posted: Thu Jul 21, 2011 3:32 pm
by Kaubs
Turns out that the image was being stripped of data by the post command. The image was being made web friendly and all "+" that the image contained were being converted to "_". A php script on the server I am posting to that reverts those changes fixed the issue. What a pain! lol!!!!

Kaubs