View Full Version : how to pass array of <input type='file'> with prototype.js

08-07-2008, 01:32 PM
hi to all

I am unsing prototype.js for ajax. I am making a image/doc upload program. In which i am repeating the <input tpye='file'> option in a loop as desired by user. here's the code

for($i=1; $i<=$max_no_img; $i++){
<td>Document <?php echo $i ?></td>
<td><input type="file" name="images[]" /></td>
<?php } ?>

Now i want to pass the values for these three files with the help of ajax but its not sending... the code is

function upload_documents() {
new Ajax.Request("upload_doc.php",
method: 'post',

postBody: '&images='+ $F('images'),
onComplete: upload_documentsResponse

function upload_documentsResponse(req){

$('show_per').innerHTML= req.responseText;

and further more i now have a requirement for only 3 uploads then i removed the loop, made 3 files input tag then den submitted with ajax.
Now came another problem
when i am echoing the files name with $_POST[] , it is printing the whole file name but when i am using

$_FILES['images1']['name'] it not printing anyting I know tat $FILES is a multidimensional array so i even tried printing with foreach statement then too its not printing anything.

Thanks in advance for any help........

08-07-2008, 01:56 PM
AFAIK a HTTP request by javascript cannot perform an upload. The actual form must be submitted and the browser's form handling must perform the upload.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum