Upload to Share-online with cUrl

Status
Not open for further replies.

skinner

Active Member
741
2010
59
5,180
Hi,

I'm trying to upload to share-online with php and this is the simple code I use:

PHP:
$linkSO = "http://".$SessionName21[1]."/upv3.php";
   			$postfieldsSO = array('username' => 'user', 'password' => 'pass', 'upload_session' => $SessionName21[0], 'chunk_no' => '1', 'chunk_number' => '1', 'filesize' => $sizeFileUPLOAD, 'fn' => '@'.$source_file, 'finalize' => '1'); 
			
			
			$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $linkSO);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfieldsSO);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$postResultSO = curl_exec ($ch);
curl_close ($ch);

but it says : no input file;

What I do wrong?

Thanks
 
12 comments
try this
PHP:
function shareonlinebiz_getsession($user,$pass){

    $url = "http://www.share-online.biz/upv3_session.php";
    $postdata = array();
    $postdata['username'] = $user;
    $postdata['password'] = $pass;
    $strpage = curl_func($url,$postdata,'','',0);
    return $strpage;
}    


function shareonlinebizupload($filename,$filelocation,$username, $password){    
    $data = shareonlinebiz_getsession($username,$password);
    $data = explode(';',$data);
    $fpost = array();
    $fpost["username"] = $username;
    $fpost["password"] = $password;
    $fpost["upload_session"] = $data[0];
    $fpost['chunk_no'] = '1';
    $fpost['chunk_number'] = '1';
    $fpost['filesize'] = filesize($filelocation);
    $fpost['fn'] = "@".$filelocation;
    $fpost["finalize"] = "1";    
    
    //printr($fpost);
    $server = 'http://'.$data[1];
    //echo $server;
    $page = curl_func($server,$fpost,'','',0);
    echo $page;
    $data = explode(';',$page);
    $download_link=$data[0];
    return $download_link;
}
 
try this
PHP:
function shareonlinebiz_getsession($user,$pass){

    $url = "http://www.share-online.biz/upv3_session.php";
    $postdata = array();
    $postdata['username'] = $user;
    $postdata['password'] = $pass;
    $strpage = curl_func($url,$postdata,'','',0);
    return $strpage;
}    


function shareonlinebizupload($filename,$filelocation,$username, $password){    
    $data = shareonlinebiz_getsession($username,$password);
    $data = explode(';',$data);
    $fpost = array();
    $fpost["username"] = $username;
    $fpost["password"] = $password;
    $fpost["upload_session"] = $data[0];
    $fpost['chunk_no'] = '1';
    $fpost['chunk_number'] = '1';
    $fpost['filesize'] = filesize($filelocation);
    $fpost['fn'] = "@".$filelocation;
    $fpost["finalize"] = "1";    
    
    //printr($fpost);
    $server = 'http://'.$data[1];
    //echo $server;
    $page = curl_func($server,$fpost,'','',0);
    echo $page;
    $data = explode(';',$page);
    $download_link=$data[0];
    return $download_link;
}

It could work, but I need your curl_func, Thanks :)
 
PHP:
function curl_func($link, $postfields = '', $cookie = '', $refer = '', $header = 1, $follow = 1, $usragent = ''){

    $ch = curl_init($link);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    if($header)
        curl_setopt($ch, CURLOPT_HEADER, 1);
    else
        curl_setopt($ch, CURLOPT_HEADER, 0);         
    if($follow)
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    else
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); 
    if($usragent)    
       curl_setopt($ch, CURLOPT_USERAGENT, $usragent);
    else
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
    
    if($refer)
        curl_setopt($ch, CURLOPT_REFERER, $refer);
        
    if($postfields){
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    }
    if($cookie){
        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
    }
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
    $page = curl_exec($ch);

    curl_close($ch);

    if(empty($page)){
        echo "<br/>Could not connect to host: <br/> $link <br/>";
        //die();
    }
    else{
        return $page;
    }
}
 
This for you - Tested By me and work good

PHP:
<?php
/*
Upload to Share-online with cUrl
Fixed By: AdelSBM
*/


//----------------------------------
$user="0123456789";  // Username
$pass="HgHFGhFsfS";    // Password

$filelocation="999.rar";  // file Path
//-----------------------------------

shareonlinebizupload($filename,$filelocation,$user, $pass); // Let's upload


function shareonlinebiz_getsession($user,$pass){

    $url = "http://www.share-online.biz/upv3_session.php";
    $postdata = array();
    $postdata['username'] = $user;
    $postdata['password'] = $pass;
    $strpage = curl_func($url,$postdata,'','',0);
    return $strpage;
}    


function shareonlinebizupload($filename,$filelocation,$user, $pass){    
    $data = shareonlinebiz_getsession($user,$pass);
    $data = explode(';',$data);
    $fpost = array();
    $fpost["username"] = $user;
    $fpost["password"] = $pass;
    $fpost["upload_session"] = $data[0];
    $fpost['chunk_no'] = '1';
    $fpost['chunk_number'] = '1';
    $fpost['filesize'] = filesize($filelocation);
    $fpost['fn'] = "@".$filelocation;
    $fpost["finalize"] = "1";    
    
    //printr($fpost);
    $server = 'http://'.$data[1];
    //echo $server;
    $page = curl_func($server,$fpost,'','',0);
    $data = explode(';',$page);
    $download_link=$data[0];
    echo $download_link;
}  
function curl_func($link, $postfields = '', $cookie = '', $refer = '', $header = 1, $follow = 1, $usragent = ''){

    $ch = curl_init($link);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    if($header)
        curl_setopt($ch, CURLOPT_HEADER, 1);
    else
        curl_setopt($ch, CURLOPT_HEADER, 0);         
    if($follow)
        @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   else
       @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); 
    if($usragent)    
       curl_setopt($ch, CURLOPT_USERAGENT, $usragent);
    else
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
    
    if($refer)
        curl_setopt($ch, CURLOPT_REFERER, $refer);
        
    if($postfields){
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    }
    if($cookie){
        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
    }
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
    $page = curl_exec($ch);

    curl_close($ch);

    if(empty($page)){
        echo "<br/>Could not connect to host: <br/> $link <br/>";
        //die();
    }
    else{
        return $page;
    }
} 

?>
 
The version of adelsbm didn't work for me, Ive needed to add this line in the function shareonlinebizupload:
PHP:
$filelocation = realpath($filelocation);

The full working script:
PHP:
<?php
/*
Upload to Share-online with cUrl
Fixed By: AdelSBM and Bronko
*/


//----------------------------------
$user="0123456789";  // Username
$pass="HgHFGhFsfS";    // Password

$filelocation="999.rar";  // file Path
//-----------------------------------

shareonlinebizupload($filename,$filelocation,$user, $pass); // Let's upload


function shareonlinebiz_getsession($user,$pass){

    $url = "http://www.share-online.biz/upv3_session.php";
    $postdata = array();
    $postdata['username'] = $user;
    $postdata['password'] = $pass;
    $strpage = curl_func($url,$postdata,'','',0);
    return $strpage;
}    


function shareonlinebizupload($filename,$filelocation,$user, $pass){    
    $filelocation = realpath($filelocation);
    $data = shareonlinebiz_getsession($user,$pass);
    $data = explode(';',$data);
    $fpost = array();
    $fpost["username"] = $user;
    $fpost["password"] = $pass;
    $fpost["upload_session"] = $data[0];
    $fpost['chunk_no'] = '1';
    $fpost['chunk_number'] = '1';
    $fpost['filesize'] = filesize($filelocation);
    $fpost['fn'] = "@".$filelocation;
    $fpost["finalize"] = "1";    
    
    //printr($fpost);
    $server = 'http://'.$data[1];
    //echo $server;
    $page = curl_func($server,$fpost,'','',0);
    $data = explode(';',$page);
    $download_link=$data[0];
    echo $download_link;
}  
function curl_func($link, $postfields = '', $cookie = '', $refer = '', $header = 1, $follow = 1, $usragent = ''){

    $ch = curl_init($link);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    if($header)
        curl_setopt($ch, CURLOPT_HEADER, 1);
    else
        curl_setopt($ch, CURLOPT_HEADER, 0);         
    if($follow)
        @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   else
       @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); 
    if($usragent)    
       curl_setopt($ch, CURLOPT_USERAGENT, $usragent);
    else
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
    
    if($refer)
        curl_setopt($ch, CURLOPT_REFERER, $refer);
        
    if($postfields){
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    }
    if($cookie){
        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
    }
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
    $page = curl_exec($ch);

    curl_close($ch);

    if(empty($page)){
        echo "<br/>Could not connect to host: <br/> $link <br/>";
        //die();
    }
    else{
        return $page;
    }
} 

?>
 
didn't work for me :(


In this line, he tells me it was an error


PHP:
$server = 'http://'.$data[1];
Need this script with LINK OUTPUT, can anyone help?
Please check the script again!
 
didn't work for me :(


In this line, he tells me it was an error


PHP:
$server = 'http://'.$data[1];
Need this script with LINK OUTPUT, can anyone help?
Please check the script again!
That's because something goes wrong in this function: shareonlinebiz_getsession
Check your username/password and try again. If that doesn't work, just output the server reply to see what's wrong.
 
Status
Not open for further replies.
Back
Top