Curl file upload problem
$5-10 USD
Paid on delivery
I am using the following code to upload a file to a website. But it doesn't work. $postResult returns an empty string
and the file upload isn't successful. If I change $url to localhost I get Request Entity Too Large.
$filename = $this->get_csv_filename($this->site_id);
$url = $this->domain."/file?action=upload&tpl=tpl&list_price_ratio=&best_price_ratio=&quality=0&multi_ok=false&submitbtn=Envoyer";
$useragent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)";
$usecookie = basename($_SERVER["SCRIPT_NAME"], '.php')."[url removed, login to view]";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('adv_file'=>"@$filename"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_MAXREDIRS , 10);
curl_setopt($ch, CURLOPT_USERAGENT , $useragent);
curl_setopt($ch, CURLOPT_COOKIEJAR, $usecookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $usecookie);
$postResult = curl_exec($ch);
curl_close($ch);
print "$postResult";
The task is to help me successfully upload the file to the website.
Project ID: #3198746