I create a php script to upload a file to megaupload on my account but I have some problem on the upload part. I'm using Curl with php.
I set the following options:
CURLOPT_POST => 1
CURLOPT_USERAGENT => "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
CURLOPT_FRESH_CONNECT => 1
CURLOPT_RETURNTRANSFER => 1
CURLOPT_FORBID_REUSE => 1
CURLOPT_TIMEOUT => 10
CURLOPT_COOKIE => session_name() . '=' . session_id()
CURLOPT_COOKIE => realpath($cookie)
CURLOPT_COOKIEJAR => realpath($cookie)
CURLOPT_COOKIEFILE => realpath($cookie)
I send a first post to connect to my acount. This part seem to work, when I check the acount page I get my info.
Then I try to send a file with the multiupload form
$multi = $this->getPage("/multiupload/index.php");
preg_match('#http://[w]{3}[0-9]#', $multi, $match);
$startPos = strpos($multi, $match[0]);
$endPos = strpos($multi, "\"", $startPos);
$link = substr($multi, $startPos, $endPos - $startPos);
echo "Link = " . $link . "\n";
$startPos = strpos($link, "UPLOAD_IDENTIFIER=") + 18;
$endPos = strlen($link);
$id = substr($link, $startPos, $endPos - $startPos);
echo "id = " . $id . "\n";
$this->setPost(array ("sessionid" => "" . $id . "",
"UPLOAD_IDENTIFIER" => "" . $id . "",
"file" => "@" . realpath($fileName),
"message" => "abc",
"toemail" => "",
"fromemail" => "",
"password" => "",
"trafficurl" => "",
"multiemail" => ""));
$page = $this->getPage($link, 1);
But I receive a "Empty reply" answer
I can't figure out why my request is wrong.
Thank you for your answers.