Jump to content

how pass array of <input type='file'> with prototype.js


Jawed

Recommended Posts

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

 

<?php

for($i=1; $i<=$max_no_img; $i++){

?>

  <tr>

    <td>Document <?php echo $i ?></td>

    <td><input type="file"  name="images[]"  /></td>

  </tr>

  <?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........

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.