473,394 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

libcurl - how to simulate multiple file upload in array

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.
Nov 29 '05 #1
0 4457

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: TK | last post by:
I have a file upload control to allow a user to select/upload a file to the server. They need to upload x number of files in one shot because they have to confirm that they are uploading x number...
0
by: mahesh anasuri | last post by:
Hi all, I am new to this mailing list. Thankful if any one is using curl/linux version to and worked on Https. I have created certificates (PEM format) for client and server using openSSL. I...
0
by: Raj | last post by:
Hi, I am newbie to programming with libcurl. the problem is i want to send my gmail username and password outside the browser and get access to my mail. this i am doing with LibCurl. Though i dont...
0
by: Raj | last post by:
Hi, I am newbie to programming with libcurl. the problem is i want to send my gmail username and password outside the browser and get access to my mail. this i am doing with LibCurl. Though i dont...
6
by: Vic Spainhower | last post by:
Hello, I am trying to do a FTP file upload which works fine on my localhost but on my ISP server it fails. I can't seem to find where I can go to find the specific cause of the failure. In both...
2
by: borucik | last post by:
I am trying to use libcurl with Visual C++ 2005 Express Edition. I downloaded the file from here: http://curl.haxx.se/dlwiz/?type=lib&os=Win32&flav=-&ver=2000%2FXP It is the 7.16.0 version of the...
1
by: fortwilliam | last post by:
Hi, I am very new to "object oriented programming". I have this script which I didn't write but have altered and have been using for a while to allow people to upload files to a website. Now I am...
4
by: MoroccoIT | last post by:
Greetings - I saw somewhat similar code (pls see link below) that does mupltiple files upload. It works fine, but I wanted to populate the database with the same files that are uploaded to...
2
by: srinivembu | last post by:
Hi, I have linked libcurl library (v7.19.6) statically with my C++ application. Using curl, we upload & download files to/from the window azure storage webservice using https. The download works...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.