cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Question about options in FORM POST Multipart

From: Pierre <junk_at_regne.net>
Date: Sat, 24 Dec 2005 12:53:53 +0100

Another information :

POST original code :

<form action="http://imageshack.us/index.php" method="post"
enctype="multipart/form-data" target="_blank">
<span style="color: #000000">Image Hosting by <a
href="http://imageshack.us/" target="_blank">ImageShack</a></span> - <a
href="http://reg.imageshack.us/content.php?page=rules"
target="_blank">ToS</a><br />

<input type="hidden" name="MAX_FILE_SIZE" value="1048576">
<input type="hidden" name="aff" value="">
<input type="hidden" name="type" value="blank">
<input type="file" class="textfield" name="fileupload" size="30"><br />
<input type="submit" value="host it!">
<span style="color: #000000">patience during upload</span><br />
</form>

WHat I've tried in CURL command line :

C:\temp\curl-7.15.1-win32-nossl-sspi\curl-7.15.1>curl -e
http://imageshack.us/if
rame.html -F fileupload=@g3829.png http://imageshack.us/index.php
curl: (55) Send failure: Connection was aborted

C:\temp\curl-7.15.1-win32-nossl-sspi\curl-7.15.1>curl -F
fileupload=@g3829.png h
ttp://imageshack.us/index.php

// I GUESS I have a problem with the http:// in the beginning of the URL
, I remove it

C:\temp\curl-7.15.1-win32-nossl-sspi\curl-7.15.1>curl -F
fileupload=@g3829.png i
mageshack.us/index.php

C:\temp\curl-7.15.1-win32-nossl-sspi\curl-7.15.1>curl -e
http://imageshack.us/if
rame.html -F fileupload=@g3829.png imageshack.us/index.php

//I am testing this on my own form, locally

C:\temp\curl-7.15.1-win32-nossl-sspi\curl-7.15.1>curl -e
http://imageshack.us/if
rame.html -F fichier=@g3829.png -F action=upload cthulhu/letslove/trav
ail/submitfile/index.php

a : upload<br \>C:\Program Files\EasyPHP1-7\tmp\php34.tmp<br \>fichier
uploadÚ v
oilÓ il est lÓ :
http://cthulhu.regne.net/letslove/travail/submitfile/index.phpm
aching3829.png<br \>

//THAT WORKED I find my file back in the directory the script puts it !

C:\temp\curl-7.15.1-win32-nossl-sspi\curl-7.15.1>curl -e
http://imageshack.us/if
rame.html -F fileupload=@g3829.png -F MAX_FILE_SIZE=1048576 -F aff= -F
type=blan
k imageshack.us/index.php

C:\temp\curl-7.15.1-win32-nossl-sspi\curl-7.15.1>curl -e
http://imageshack.us/if
rame.html -F fileupload=@g3829.png -F MAX_FILE_SIZE=1048576 -F
type=blank images
hack.us/index.php

C:\temp\curl-7.15.1-win32-nossl-sspi\curl-7.15.1>curl -e
http://imageshack.us/if
rame.html -F fileupload=@g3829.png -F MAX_FILE_SIZE=1048576 -F
type=blank -A "Mo
zilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" imageshack.us/index.php

It always returns me : nothing, I'll try using the trace-ascii option
and LiveHTTPHeader for mozilla ... But if someone could give me some hint =)

Thank you

Pierre wrote:
> Hi, I am all new to CURL, but I am stuck in a FORM POST method,
> Multipart enctype , submitting.
>
> I've made my own form somewhere, then submit a file and values to it,
> using the command line tool, or a php script, this is working.
>
> But I really can't send anything to the url :
>
> http://imageshack.us/iframe.php
>
> ( with requests the file to be a picture )
>
> When I try to submit it in the command line I get NOTHING in return.
>
> Via my php script , I get : "1" instead of the result page.
>
> When you use the page directly, this is working, when you copy the code
> to you own webserver, this is still working ( no host filter then )
>
> I guess I must pass other options in my request and many other more to
> let CURL act EXACTLY as the original HTTP POST form.
>
> Can someone help me ?
>
> Thank you.
>
> ---
>
> My PHP SCRIPT ( working to submit self made POST FORMs )
>
> <?php
>
> $url='http://imageshack.us/index.php';
>
> $postData = array();
>
> $postData[ 'fileupload' ] = "@".$fichier;
> $postData[ 'submit' ] = "upload";
> $postData[ 'type' ] = "blank";
> $postData[ 'aff' ] = "";
> $postData[ 'MAX_FILE_SIZE' ] = "1048576";
>
> $ch = curl_init();
>
> curl_setopt($ch, CURLOPT_URL, $url );
> curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
> curl_setopt($ch, CURLOPT_POST, 1 );
> curl_setopt($ch, CURLOPT_INFILESIZE, filesize($fichier) );
>
> curl_setopt($ch, CURLOPT_POSTFIELDS, $postData );
>
> $response = curl_exec( $ch );
>
> //echo curl_error($ch);
> curl_close($ch);
>
>
> echo $response;
>
> ?>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2005-12-24