Hey, ich versuche via PHP Files auf load.to zu schieben, bekomme aber immer nur ein "WARNING: Could not get hash sum of file." zurück.
Ich hab hier folgenden Code.
Das ist dann die Upload FunktionPHP-Code:function request($url, $data = array(), $enableCookies = true, $redirect = false, $file = null, $fileFieldName = null) {
$ch = curl_init($url);
$userAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:11.0) Gecko/20100101 Firefox/11.0';
if($enableCookies) {
curl_setopt($ch, CURLOPT_COOKIEFILE, cookie($url));
curl_setopt($ch, CURLOPT_COOKIEJAR, cookie($url));
}
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); // empty user agents probably not accepted
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $redirect);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1); // enable this - they check referer on POST
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if($file) {
if(!file_exists($file))
{
throw new Exception('File not found');
}
$curl_file = new CurlFile(realpath($file), mime_type($file), basename($file));
$field = ($fileFieldName ? $fileFieldName : 'file');
$data[$field] = $curl_file;
}
if(count($data)) {
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
$response = curl_exec($ch);
$result = array(
'contents' => $response,
'request' => array(
'statusCode' => curl_getinfo($ch, CURLINFO_HTTP_CODE),
'info' => curl_getinfo($ch)
)
);
curl_close($ch);
return $result;
}
function cookie($url) {
return 'cookies/'.parse_url($url, PHP_URL_HOST).'.cookie';
}
function mime_type($file){
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime_type = finfo_file($finfo, realpath($file));
finfo_close($finfo);
return $mime_type;
}
Ich denke das soweit alles korrekt ist, aber wie gesagt es funktioniert nicht. Wenn ich mir Chrome Debug angucke kommt die loadto_upload.pl gar nicht vor, im Quelltext steht sie aber.PHP-Code:function loadTo_upload($file, $username = null, $password = null){
if(!file_exists($file))
{
throw new Exception('File not found');
}
// wir holen uns die upload url
$page = request('https://www.load.to')['contents'];
if(!preg_match("~form name=\"form_upload\" method=\"post\" enctype=\"multipart/form-data\" action=\"(.*?)\"~", $page, $matches))
{
return false;
}
// link zur voll url upgraden
$upload_url = preg_replace('#\/\/s(.*)#', 'http://s$1', $matches[1]);
var_dump($upload_url);
// upload!!!
$data['email'] = '';
$data['filecomment'] = '';
$data['imbedded_progress_bar'] = 1;
$data['upload_range'] = 1;
$page = request($upload_url, $data, false, true, $file, 'upfile_0')['contents'];
echo $page;
// form name="form_upload" method="post" enctype="multipart/form-data" action="//s1.load.to/cgi-bin/loadto_upload.pl?tmp_sid=dfc60736beefd7d9db93fa743b0d8754&config_file=loadto"
}
Hat jemand ne Idee? Wäre sehr dankbar.
lg




Zitieren