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

curl-and-php

Set filename in POST

From: PPCM <ppcm_at_ifrance.com>
Date: Tue, 27 Mar 2007 15:39:18 +0200

Hello there,

The background:
I need to send files to a server using a POST form.
But my files are not stored with their real names but with their archine
names.
I need to send files throw their real names.

Using cURL (command line)
I succeed to send files with curl using a different name for the upload
file than the name stored on the disk:

curl -F 'file=@archivename.tar.gz;filename=realname.tar.gz'
http://servername.com

Using libcurl
But I can't do the same thing with libcurl, here is the code:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, http://servername.com);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' =>
'@archivename.tar.gz;filename=realname.tar.gz'));
    $postResult = curl_exec($ch);
    curl_close($ch);

I have the following error:
    failed creating formpost data

And I can't find a solution...
(It should be better if I don't use the shell_exec function)

Does somebody have an idea how to solve my problem?

Thanks

Pierre

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2007-03-27