Mobile App Sending Image File to PHP Server
I am trying to send an image file to a php server. What am I doing wrong?
var xhr = Titanium.Network.createHTTPClient();
xhr.open('POST',<url>);
filename = 'img.png';
xhr.send({media: filename});
// Then on the php side I have
$tmpfile = $_FILES['media']['tmp_name']; // ==> to get at the file information
.
.
any and all help is appreciated. Thanks.
3 Answers
-
Hey Rob, Thanks for the response. For others here is the code that works.
var xhr = Titanium.Network.createHTTPClient(); xhr.open('POST',<url>); filename = 'img.png'; f1 = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,filename); iamge=f1.read(image); xhr.send({media: image});
-
In your example filename is a string. You need to send the raw file data over in the send({media:filename})
-
Hi,
Can you please help me out in this issue:
http://developer.appcelerator.com/question/8471/upload-images-to-a-server
and here:
http://stackoverflow.com/questions/2532478/how-to-upload-images-from-iphone-app-developed-using-titanium