July 27, 2010

[SOLVED] PHP: How upload file using cURL?


<?php
$request_url = ‘http://www.akchauhan.com/test.php’;
$post_params['name'] = urlencode(’Test User’);
$post_params['file'] =@.'demo/testfile.txt’;
$post_params['
submit'] = urlencode(’submit’);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$result = curl_exec($ch);
curl_close($ch);
?>


Source: How upload file using cURL?.

No comments:

Post a Comment