Sunday, 15 January 2012

Uploading image to a submit form via PHP and curl -



Uploading image to a submit form via PHP and curl -

i have upload set of images submit form in page. think can done php , curl. when checked submit form action file, noticed using post request payloads upload images.

can help me in telling how add together payload post request. need basic knowledge along sample code how images uploaded server etc. tried number of codes here , there on so, none of them worked out case. so, thought going through basics more of import ! able write case.

updates :-

i have come solution

function curl_post_request($url, $data, $referer='') { $data = http_build_query($data); $c = curl_init(); curl_setopt($c, curlopt_url, $url); curl_setopt($c, curlopt_returntransfer, true); curl_setopt($c, curlopt_header, true); curl_setopt($c, curlopt_post, true); curl_setopt($c, curlopt_postfields, $data); curl_setopt($c, curlopt_referer, $referer); curl_setopt($c, curlopt_useragent, "mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.8.1.1) gecko/20061204 firefox/2.0.0.1"); curl_setopt($c, curlopt_header, $headers); curl_setopt($c, curlinfo_header_out, true); curl_setopt($c, curlopt_verbose, true); $output = curl_exec($c); var_dump(curl_getinfo($c, curlinfo_header_out)); if($output === false) trigger_error('erreur curl : '.curl_error($c),e_user_warning); curl_close($c); homecoming $output; } if(isset($_get['go'])) { $data = array( 'file_0' => "@".realpath('rupee.png'), 'file_1' => "@".realpath('sel.jpg') ); $url = 'http://demo.ipol.im/demo/my_affine_sift/input_upload'; print_r($data); $a = curl_post_request($url, $data); var_dump($a); } else { print_r($_post); print_r($_files); }

output of code can seen here

issue being, files uploading should have attribute filename. also, unable add together attribute it. tried changing $data array using. solution ?

further update :-

added filename attribute , still the receiving end not able filename :(

$data = array( 'file_0' => '@'.realpath("rupee.png").';filename='.$filename1, 'file_1' => '@'.realpath("sel.jpg").';filename='.$filename2 );

thanks !

php curl image-uploading

No comments:

Post a Comment