|
Posted by Yandos on 11/24/05 13:52
Hi php gurus,
I need to create an array which will contain more keys with same name,
but of different values. I have no idea how to do it. Could you please
help me?
This is what I'd like to do:
$postdata=array("senderid"=>"1111", "senderpass"=>"blah",
"userfile[]"=>"@newclients.csv", "userfile[]"=>"@invoices.csv");
But userfile[] will be stored in that array only once, so I cannot use
it to feed libcurl for automated file upload :(
Is this possible to handle somehow in php? It think it is either trivial
or impossible, but i'm clueless at this point :( (If that's trivial,
please try to be patient and don't kill me for stupid question :) )
Thank you in advance,
Y.
Here's more info for those who are interested why do I need it:
The $postdata will be posted by curl to the page which looks almost
exactly like copied from PHP help:
<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 initialize curl and upload (this works fine, but i need to upload both
files at once, and i cannot set them with single pass)
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $submitlink);
curl_setopt ($ch, CURLOPT_VERBOSE, 0);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_exec($ch);
Best would be if I could convince the author of that webpage to use
<input name="userfile1" type="file"><br>
<input name="userfile2" type="file"><br>
and then it would work fine, but that's what I can't :(
Navigation:
[Reply to this message]
|