Skip to content
WJunction - Webmaster Forum

CURL - postfields how to replicate these headers

Status
Not open for further replies.
Code:
-----------------------------30870195987994
Content-Disposition: form-data; name="file[]"; filename=""
Content-Type: application/octet-stream


-----------------------------30870195987994
Content-Disposition: form-data; name="file[]"; filename="K43TA206.zip"
Content-Type: application/zip
So I'm trying to write a basic curl upload script for bitshare. I know there is a rapidleech plugin for it, but I'm just wondering how do I pass the empty file as a post field. Bitshare is weird in that they post an empty file array in their header. If I leave it out, the upload does not work.

In the rapidleech plugin, they open a socket and literally just paste that exact section. For curl I pass in an array format usually.

array ( "file[]" => "@$filename");

I've tried

PHP:
array ( "file[]" => "", "file[]" => "@$filename" )
But it doesn't work. Any help would be appreciated.
 

8 comments

you have to send 2 variables in your post array, one with filename and other with location, here is example for bitshare.

PHP:
              $postData = array(
					'APC_UPLOAD_PROGRESS' => $progress_key,
					'APC_UPLOAD_USERGROUP' => $usergroup_key,
					'UPLOAD_IDENTIFIER' => $progress_key,
					'file[]"; filename="' => basename($filelocation),
					'file[]' => $filelocation
					);
 
try
PHP:
"file[]=&file[]={@$filename}"

Do I append this to the postdata array?

you have to send 2 variables in your post array, one with filename and other with location, here is example for bitshare.

PHP:
              $postData = array(
                    'APC_UPLOAD_PROGRESS' => $progress_key,
                    'APC_UPLOAD_USERGROUP' => $usergroup_key,
                    'UPLOAD_IDENTIFIER' => $progress_key,
                    'file[]"; filename="' => basename($filelocation),
                    'file[]' => $filelocation
                    );

What happens to the usual @ infront of the file?

Thanks for your suggestions!

EDIT: I've tried what mRaza suggested and this is the headers returned from CURL.

Code:
HTTP/1.1 100 Continue HTTP/1.1 200 OK Server: nginx/0.8.50 Date: Wed, 24 Aug 2011 02:38:25 GMT Content-Type: text/html Transfer-Encoding: chunked Connection: close X-Powered-By: PHP/5.3.0 no files
 
Last edited:
Oh so in the form of a GET?

So when i post with just
PHP:
$post = "file[]=&file[]={@$x}";


The header returned is:
Code:
HTTP/1.1 200 OK Server: nginx/0.8.50 
Date: Wed, 24 Aug 2011 03:34:12 GMT 
Content-Type: text/html 
Transfer-Encoding: chunked 
Connection: close 
X-Powered-By: PHP/5.3.0  

wrong parameter count
So when I post with the required fields:
PHP:
$post = "APC_UPLOAD_PROGRESS={$progress_key}&APC_UPLOAD_USERGROUP={$usergroup_key}&UPLOAD_IDENTIFIER={$progress_key}&file[]=&file[]={@$x}";
The header returned is:
Code:
HTTP/1.1 200 OK
Server: nginx/0.8.50
Date: Wed, 24 Aug 2011 03:38:07 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: close
X-Powered-By: PHP/5.3.0


Notice: Undefined index: file in /var/www/fs/x/upload.php on line 18
no files
 
What happens to the usual @ infront of the file?
you have to add @ in file location:
PHP:
              $postData = array(
					'APC_UPLOAD_PROGRESS' => $progress_key,
					'APC_UPLOAD_USERGROUP' => $usergroup_key,
					'UPLOAD_IDENTIFIER' => $progress_key,
					'file[]"; filename="' => basename($filelocation),
					'file[]' => "@$filelocation"
					);
 
Status
Not open for further replies.

About the author

F
Established Member · Joined
257
Messages
22
Reactions
18
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