How do you Upload Image to parse.com usint REST API + PHP? -


currently using this, file stored empty, supose no data going through.

$post = array("file"=>'@'.$_files['uploadfile']['tmp_name']); $ch = curl_init(); curl_setopt($ch,curlopt_httpheader,array('x-parse-application-id : xxxxxxxxxxxxxx','x-parse-rest-api-key: xxxxxxxxx', 'content-type: image/jpeg')); curl_setopt($ch, curlopt_url, 'https://api.parse.com/1/files/'.$_files['uploadfile']['name']); curl_setopt($ch, curlopt_post,1); curl_setopt($ch, curlopt_binarytransfer, 1); curl_setopt($ch, curlopt_postfields, json_encode($post)); $result=curl_exec ($ch); curl_close ($ch); echo $result; 

got working. need send binary data post field. duh. before should create restrictions (file size, type etc)

$post = file_get_contents($_files['uploadfile']['tmp_name']); $ch = curl_init(); curl_setopt($ch,curlopt_httpheader,array('x-parse-application-id : xxxxxxxx','x-parse-rest-api-key: xxxxxxxxxxxxxxx', 'content-type: image/jpeg')); curl_setopt($ch, curlopt_url, 'https://api.parse.com/1/files/'.$_files['uploadfile']['name']); curl_setopt($ch, curlopt_post,1); curl_setopt($ch, curlopt_binarytransfer, 1); curl_setopt($ch, curlopt_postfields, $post); $result=curl_exec ($ch); curl_close ($ch); echo $result; 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -