Announced in CB to release it and here it is.
Note: It is NOT for sBorg or phpUploader or Yawn's Script! It's in cURL and since those scripts use cURL to upload, you can get an idea how to port it to one of the scripts mentioned above. Without any delay, here we go:
$x is the filename of the file to be uploaded. If you have any problems, do post and I'll try my best to sort it out
Usage: Copy paste the code above in a PHP file and then call it like this
Regards,
gunda316
Note: It is NOT for sBorg or phpUploader or Yawn's Script! It's in cURL and since those scripts use cURL to upload, you can get an idea how to port it to one of the scripts mentioned above. Without any delay, here we go:
PHP:
function uploadFiSO($x){
if(!file_exists(dirname(__FILE__).'\fisocookie.txt'))
{
//Login if there is no cookie
$val = postHost("http://www.filesonic.in/user/login", "email=$username&redirect=%2F&password=$password","", 'fisocookie.txt');
}
$cook = file_get_contents('fisocookie.txt');
preg_match('/PHPSESSID.*/', $cook, $match);
$sessionID = trim(str_replace('PHPSESSID', '', $match[0]));
$millisec = round((microtime(true) * 1000.0));
$random = rand(0,90000);
$url = 'http://s115.filesonic.in/?X-Progress-ID=upload_'.$millisec.'_'.$sessionID.'_'.$random;
$post = array('upload[]' => "@$x");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, trim($url));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'\fisocookie.txt');
//curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); //Damn HTTP Error 417
$result = curl_exec($ch);
if(curl_errno($ch)){
echo "ERROR - " . curl_error($ch);
}
curl_close($ch);
$result = postHost('http://www.filesonic.in/upload-completed/upload_'.$millisec.'_'.$sessionID.'_'.$random, '',dirname(__FILE__).'\fscookie.txt');
preg_match('/F[0-9]+/', html_entity_decode($result), $match);
echo 'http://www.filesonic.com/file/'.str_replace('F','',$match[0]).'/'.$x;
}
function postHost($url, $data, $cookie, $storCook = null){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
if($cookie != "")
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
if($data != ""){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
if(isset($storCook)){
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'\\'.$storCook);
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'\\'.$storCook);
}
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
$page = curl_exec($ch);
curl_close($ch);
return $page;
}
Usage: Copy paste the code above in a PHP file and then call it like this
PHP:
uploadFiSO('/path/to/file');
Regards,
gunda316
Last edited: