Curl file upload problem

Cancelled Posted Mar 25, 2011 Paid on delivery
Cancelled 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.

Amazon Web Services PHP Software Architecture Software Testing Web Hosting Website Management Website Testing

Project ID: #3198746

About the project

1 proposal Remote project Active Mar 25, 2011

1 freelancer is bidding on average $9 for this job

pateman

See private message.

$8.5 USD in 1 day
(53 Reviews)
4.7