|
Posted by Stefan Rybacki on 08/04/05 13:41
Shailesh Patel wrote:
> hi Stefan,
> thnax for ur reply,i got ur point. but i want to do same
> thing via php curl library not by curl command prompt.
> i searched for curl_setopt options. but bad luck.:( not found.
>
then read again!
"Multipart form uploads (ie simulating the upload of files from a browser form) is
surprisingly easy, yet hard to find information on.... hope this changes that.
$postData = array();
//simulates <input type="file" name="file_name">
$postData[ 'file_name' ] = "@test.txt";
$postData[ 'submit' ] = "UPLOAD";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1 );
//seems no need to tell it enctype='multipart/data' it already knows
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData );
$response = curl_exec( $ch );
//where test.txt is a file in the same directory!"
Navigation:
[Reply to this message]
|