curl-users
Re: pb with http post request (form) and attached file
Date: Wed, 24 Oct 2007 06:10:00 -0700
Frédéric Plé wrote:
> Here is the command line I use :
> curl -s -o /dev/null -b ./cookie.txt -F folderid=7 -F
> 'userfile=@/tmp/4153/29 E-MAILING, FAX-MAILING ET MAILING.DOC' -F
> expires=false -F sequence=1 'http://localhost/form-script.php'
>
> When I run the curl command with strace, I have this error :
> open("/tmp/4153/29 E-MAILING", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No
> such file or directory)
>
> As you can see, the filename is cut when encounters comma.
From the manual:
> -F accepts parameters like -F "name=contents". If you want the contents to
> be read from a file, use <@filename> as contents. When specifying a file,
> you can also specify the file content type by appending ';type=<mime type>'
> to the file name. You can also post the contents of several files in one
> field. For example, the field name 'coolfiles' is used to send three files,
> with different content types using the following syntax:
>
> curl -F "coolfiles=@fil1.gif;type=image/gif,fil2.txt,fil3.html" \
> http://www.post.com/postit.cgi
Note that the comma is used to delimit multiple filenames, and so curl
thinks that you're trying to specify a list of two filenames. I think
you can work around this by urlencoding the comma.
Brian
Received on 2007-10-24