Check if upload failed

Status
Not open for further replies.
6 comments
For example, I use that functions:

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;
    }
} 

?>
 
you can try to use stristr function

PHP:
$download_link = shareonlinebizupload($filename,$filelocation,$user, $pass); // Let's upload
if(stristr($download_link,'share-online.biz')) echo 'uploaded';
else echo 'failed'; //or upload again
 
you can try to use stristr function

PHP:
$download_link = shareonlinebizupload($filename,$filelocation,$user, $pass); // Let's upload
if(stristr($download_link,'share-online.biz')) echo 'uploaded';
else echo 'failed'; //or upload again

So I have to add

PHP:
$download_link = shareonlinebizupload($filename,$filelocation,$user, $pass);

in the ELSE?
 
Status
Not open for further replies.
Back
Top