You are here: libcurl - how to simulate multiple file upload in array « PHP Programming Language « IT news, forums, messages
libcurl - how to simulate multiple file upload in array

Posted by Yandos on 11/29/05 18:19

Hello all,

I'm sorry for a bit off-topic post, but curl does not have own newsgroup, so I hope someone might
help me here...

I need to feed form like the following using libcurl:

<form action="file-upload.php" method="post" enctype="multipart/form-data">
<input name="senderid" value="1111" type="hidden">
<input name="senderpass" value="blah" type="hidden">
clients:<br>
<input name="userfile[]" type="file"><br>
invoices:<br>
<input name="userfile[]" type="file"><br>
<input type="submit" value="Send files">
</form>

I prepare an array and run curl:

<?php
$postdata=array("senderid"=>"1111", "senderpass"=>"blah",
"userfile"=>array("@newclients.csv", "@invoices.csv"));

$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, "http://localhost/phpinfo.php");
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
$result=curl_exec($ch);
$f=fopen("phpinfo.html","wb");
fwrite($f,$result);
fclose($f);
curl_close ($ch);
?>

When I open the phpinfo.html with browser, I see line:

_REQUEST["userfile"] Array

instead of what i'd expect...

_FILES["userfile"]

Array
(
[name] => Array
(
[0] => newclients.csv
[1] => invoices.csv
)

[type] => Array
(
[0] => application/octet-stream
[1] => application/octet-stream
)

[tmp_name] => Array
(
[0] => C:\WINDOWS\TEMP\php428.tmp
[1] => C:\WINDOWS\TEMP\php429.tmp
)

[error] => Array
(
[0] => 0
[1] => 0
)

[size] => Array
(
[0] => 24624
[1] => 13
)

)

Does it mean, that curl cannot handle multiple file uploads when they are in the same array or is
there a bug in libcurl? Is there a way how can I upload more files to the mentioned form?

Thanks anyone for kind help.

Y.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация