Skip to content

Commit

Permalink
Merge pull request #2 from kyshnirev/master
Browse files Browse the repository at this point in the history
fix: file upload
  • Loading branch information
SerjPopov authored Aug 31, 2017
2 parents 1491b65 + 2f41f70 commit 63d35f0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions CloudMailRu.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ private function loadFile_to_cloud($file_name)
$_time = time() . '0246';

$url = $this->upload_url
. '?cloud_domain=1'
. '?cloud_domain=2'
. '&x-email=' . $this->user . '%40' . $this->domain
. '&fileapi' . $_time;

$post_data = array("file" => "@" . $file_name);
$post_data = ["file" => curl_file_create($file_name)];

$this->_curl_init($url);
$this->_curl_post($post_data);
Expand Down Expand Up @@ -282,10 +282,16 @@ private function _curl_init($url)
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($this->ch, CURLOPT_COOKIEFILE, $this->dir . '/cookies.txt');
curl_setopt($this->ch, CURLOPT_COOKIEJAR, $this->dir . '/cookies.txt');
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
}

private function _curl_post($post_data)
{
curl_setopt($this->ch, CURLOPT_HTTPHEADER, [
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17',
'Referer: https://cloud.mail.ru/home/',
'Content-Type: multipart/form-data'
]);
curl_setopt($this->ch, CURLOPT_POST, true);
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post_data);
}
Expand Down

1 comment on commit 63d35f0

@polakiv
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не подскажете почему на хостинге не работает это?
разные хостинги пробовал, пишет что не проходит авторизацию

Please sign in to comment.