cURL PHP Upload Issues

Status
Not open for further replies.

rimla

Active Member
25
2010
4
80
Hello guys, I'm trying to make a plain cURL upload to hugefiles.net, but with no luck.

I have set the $data['srv_tmp_url'] manually, (hope that it can be done so) and also the upload_id parametar, to avoid any page scraping for now.

When the script executes it does redirect me to a download link, but the file there contains about 25 B.
Here is the code, hope someone can try this and point out the mistakes I am making, thanks.

Code:
<?php

function Upload_curl($url,$data)
{


        $ch = curl_init();


        
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_TIMEOUT, 1000);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,TRUE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
        curl_setopt($ch, CURLOPT_REFERER, "http://hugefiles.net/");




        $result = curl_exec($ch);    
        return $result;


}
$filename = "test.rar";
$data = array();
$data['upload_type'] = "file";
$data['srv_tmp_url'] = "http://us02.hugefiles.net/tmp";
$data['file_0; filename="'.$filename.'"'] = "@C:/xampp/htdocs/test.rar";
//$data["sess_id"] = "";



echo Upload_curl("http://us02.hugefiles.net/cgi-bin/upload.cgi?upload_id=310423971419&js_on=1&utype=&upload_type=file",$data);


?>

__________________
Added after 1 Day 18 Hours:

Ok I have added a few more fields in $post, "submit_btn" => ' Upload! ', "link_rcpt" => '', "tos" => '1', somehow I didnt saw them in fiddler, but I still get the same problem.I tried opening the file which was uploaded and it contains only a string with the path to the file I was trying to upload, in this case @C:/xampp/htdocs/test.rar".

__________________
Added after 11 Hours 36 minutes:

SOLVED.
 
Last edited:
5 comments
PHP:
<?php

function Upload_curl($url,$data)
{


        $ch = curl_init();


        
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_TIMEOUT, 1000);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,TRUE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
        curl_setopt($ch, CURLOPT_REFERER, "http://hugefiles.net/");




        $result = curl_exec($ch);    
        return $result;


}
$filename = "test.rar";
$data = array();
$data['upload_type'] = "file";
$data['srv_tmp_url'] = "http://us01.hugefiles.net/tmp";
$data['file_0; filename="'.$filename.'"'] = "@C:/xampp/htdocs/test.rar";
$data['submit_btn'] = " Telecarga! ";
$data["sess_id"] = "";




echo Upload_curl("http://us01.hugefiles.net/cgi-bin/upload.cgi?upload_id=916480837691&js_on=1&utype=&upload_type=file",$data);


?>
 
Status
Not open for further replies.
Back
Top