Hello World! Today i will show you how to submit file in php using cURL.
The most important is to add “@” symbol at the beginnig of the path. That was all the magic^^
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php $curlHandler = curl_init(); curl_setopt($curlHandler, CURLOPT_HEADER, 0); curl_setopt($curlHandler, CURLOPT_VERBOSE, 0); curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlHandler, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); curl_setopt($curlHandler, CURLOPT_URL, _VIRUS_SCAN_URL); curl_setopt($curlHandler, CURLOPT_POST, true); // as <input type="file" name="upload"> $dataFields= array( "upload"=>"@/way_to/the/file.pdf", ); curl_setopt($curlHandler, CURLOPT_POSTFIELDS, $dataFields); $response = curl_exec($curlHandler); ?> |