Hi,
I want to upload image : here is my code :
exports.addMediaToAlbum = function(idAlbum, media, name, description, success, error){ var client = Ti.Network.createHTTPClient(); client.open('POST', 'https://server.com/api/photo/'); client.setRequestHeader('Content-Type', 'multi-part/form-data'); var id; client.onerror = function(e){ error(e.error); }; client.onload = function(e) { try{ var response = this.responseText; //alert(response); success(); } catch(Err){ error(Err); } }; client.send({album: idAlbum, photo: media, name: name, description: description}); };i try to send but it doesn't work. i have the same code width curl in php and it works :
$file = new File('/path/to/file.jpg'); $fields = array( "photo" => "@".$file->getRealPath(), "name" => "superbe", "description" => "un super souvenir !", "album" => $album[0]['id'] ); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); $result = curl_exec($ch);shoud l add information to my http request object ?
thanks..
Your Answer
Think you can help? Login to answer this question!