Tizag.com Webmaster Tutorials - A collection of webmaster tutorials from HTML to PHP.

Wednesday, December 21, 2011

Uploading Multiple Files using CURL

$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");http://www.blogger.com/img/blank.gif
curl_setopt($ch, CURLOPT_URL, _VIRUS_SCAN_URL);
curl_setopt($ch, CURLOPT_POST, true);
// same as <input type="file" name="file_box">
$post = array(
"file_box1"=>"@/path/to/myfile1.jpg",
"file_box2"=>"@/path/to/myfile2.jpg",
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
-------------------------------------------------------------------------

@" sign in fromt of the file name required to upload the file

source http://dtbaker.com.au/random-bits/uploading-a-file-using-curl-in-php.html

No comments: