Skip to content
WJunction - Webmaster Forum

[req] php curl filepost.com uploader

Status
Not open for further replies.
hi dear coders, again. i am started write new script "php curl filepost.com uploader". I successfully wrote a function fpLogin, but have a problem with fpUpload. what URL to use to fill a file? help pls.

thanks.
 

23 comments

Where did you got stuck?
What was the problem here?
Show the existing code if there are problems, others will may try to fix it
 
PHP:
    function fpLogin($email, $pass) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'http://filepost.com/premium/login');
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
        curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2');
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, 'email=$email&password=$pass');
        curl_exec($ch);
        curl_close($ch);
    }

    function fpUpload($x) {
        $file = array('file' => "@$x");
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, 'http://filepost.com/files/upload/regular/');
        curl_setopt($curl, CURLOPT_COOKIEFILE, "cookie.txt");
        curl_setopt($curl, CURLOPT_HEADER, 1);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $file);
        curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2');
        $res = curl_exec($curl);
        curl_close($curl);
        echo $res;
    }
i look upload page via http fox and find
but still not working...
 
I checked your code quickly and there's an error:

PHP:
curl_setopt($ch, CURLOPT_POSTFIELDS, 'email=$email&password=$pass');
this will not work. do this:

PHP:
curl_setopt($ch, CURLOPT_POSTFIELDS, "email=$email&password=$pass");
or this:

PHP:
curl_setopt($ch, CURLOPT_POSTFIELDS, 'email='.$email.'&password='.$pass);
 
ftp upload work bad with my vps... and the download link does not appear for a long time to parse ... but if u have good solution with ftp upload method, I listen carefully :)
 
hey has anyone actually written a web/http upload for this host? Im currently using FTP however web support would be nice.
 
hey has anyone actually written a web/http upload for this host? Im currently using FTP however web support would be nice.
feeling lazy SplitIce?
here you go, just wrote now for you guys
PHP:
<?php
/**
 * written by mRAza
 * 11-09-2011
 *
 *
 * Usage: 	$link = upFilepost($user,$password,$cookie,$file);
 **/
function upFilepost($user,$password,$cookie,$file){
		$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4)Gecko/20030624 Netscape/7.1 (ax)";
		
		$post = 'email='.$user.'&password='.$password;
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, "http://filepost.com/general/login_form/");
		curl_setopt($ch, CURLOPT_USERAGENT, $agent);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
        curl_setopt($ch, CURLOPT_HEADER, 1);
		curl_setopt($ch, CURLOPT_REFERER, "http://filepost.com/");
		curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
		curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
		$result = curl_exec($ch);
		
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, "http://filepost.com/files/upload/");
		curl_setopt($ch, CURLOPT_USERAGENT, $agent);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
        curl_setopt($ch, CURLOPT_HEADER, 1);
		curl_setopt($ch, CURLOPT_REFERER, "http://filepost.com/");
		curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
		curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
		$result = curl_exec($ch);

		preg_match("#upload_url: '(.*)'#",$result,$upURL);
		$upURL =  $upURL[1];
		preg_match("#SID: '(.*)'#",$result,$SID);
		$SID = $SID[1];
      		

        $post = array();
        $post['file']="@$file";
        $post['SID']=$SID;
        $post['Filename']= basename($file);
        $post['Upload']="Submit Query";

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $upURL);
		curl_setopt($ch, CURLOPT_USERAGENT, 'Shockwave Flash');
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
        curl_setopt($ch, CURLOPT_HEADER, 1);
		curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
		curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
		$result = curl_exec($ch);

		preg_match("#answer\":\"(.*)\"#",$result,$answer);
		$answer = $answer[1];
        if ($answer ){
		
			$url = 'http://filepost.com/files/done/'.$answer.'/?JsHttpRequest';

			$ch = curl_init();
			curl_setopt($ch, CURLOPT_URL, $url);
			curl_setopt($ch, CURLOPT_USERAGENT, $agent);
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
			curl_setopt($ch, CURLOPT_HEADER, 1);
			curl_setopt($ch, CURLOPT_REFERER, "http://filepost.com/");
			curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
			curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
			$result = curl_exec($ch);
			curl_close($ch);

			preg_match("#id=\"down_link\" class=\"inp_text\" value=\"(.*)\"#",$result,$link);
			if($link) {
				return $link[1];

        }

        }
		
		return false;
		
}		


?>
 
@mRAza: Yes entirely the reason. That and my first attempt didnt work.


I see why now "$post['Filename']= basename($file);"


Thanks.
 
Good job, mRAza. As per our experience, filepost is using chunked upload. It's works fine in php (as mRAza demonstrated), but there's some problems with other languages (for example, in Perl you have to patch LWP). They also have quite interesting FTP upload.
 
Thanks it works.

Strange thing is, I used the wrong string for the pass 1st time & it still uploaded to my account.
 
Status
Not open for further replies.

About the author

H
Active Member · Joined
94
Messages
2
Reactions
8
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom