Re: Curl fiel Upload
| From: | Manuel Lemos | Date: | Wed, 21 Jan 2009 00:06:43 +0000 |
| Subject: | Re: Curl fiel Upload | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-286900@lists.php.net to get a copy of this message | ||
Hello,
on 01/20/2009 09:10 PM Matthias Laug said the following:
> I've got a problem using curl to upload a file. I want to send it to a form
> written with the Django Framework.
>
> Post Request are processed correctly, with one anomaly.
> This piece of code works fine
>
> curl_setopt($process, CURLOPT_POSTFIELDS, http_build_query($data));
>
> But if i provide only an array no data is send to the form
>
> curl_setopt($process, CURLOPT_POSTFIELDS, $data);
>
> I have read somewhere that curl sends formdata with enctype="form/mulitpart"
> only if I provide an array not a string.
>
> If I add "@filename" to the $data variable (string or array) it does not
> send the file to the form.
>
> Each example I have found in the internet so far did not work.
I do not use the Curl functions directly. When possible I use fsockopen
as alternative and use this HTTP client class to submit any kind of HTTP
requests. Take a look at the test_http_post.php to see how simple is to
submit form with one or more file uploads.
http://www.phpclasses.org/httpclient
--
Regards,
Manuel Lemos
Find and post PHP jobs
http://www.phpclasses.org/jobs/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/