WHAT'S NEW?
Loading...

Uploading a file using Curl in PHP

Source : dtbaker.com

$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;)");
curl_setopt($ch, CURLOPT_URL, _VIRUS_SCAN_URL);
curl_setopt($ch, CURLOPT_POST, true);
$post = array(
"file_box"=>"@/path/to/myfile.jpg",
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
?>
notice the @ infront of the file path, this is the magic part.

3 komentar: Leave Your Comments

  1. Blogging is the new poetry. I find it wonderful and amazing in many ways.

    BalasHapus
  2. What you're saying is completely true. I know that everybody must say the same thing, but I just think that you put it in a way that everyone can understand. I'm sure you'll reach so many people with what you've got to say.

    BalasHapus
  3. Very informative, keep posting such good articles, it really helps to know about things.

    BalasHapus