php curl 上传到megaupload
我创建了一个 php 脚本来将文件上传到我的帐户上的 megaupload,但我在上传部分遇到一些问题。 我正在将 Curl 与 php 一起使用。
我设置了以下选项:
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)
我发送第一篇帖子以连接到我的帐户。 这部分似乎有效,当我检查帐户页面时,我得到了我的信息。
然后我尝试使用多重上传表单发送文件
$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);
,但收到“空回复”答案,
我不明白为什么我的请求是错误的。
谢谢您的回答。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在此上传,
确保您通过了所有必要的邮政字段
upload here
make sure you are passing all the necessary postfields