willbeeler
willbeeler

Reputation: 689

Jquery Dynamic Form Elements - Problem

I've looked through the Related Questions section and I can't find an answer to this. I'm using PHP + Jquery. I added <input type='file' name='file[]' size='20 />' dynamically, using Jquery. However, when I Post the data, and use print_r($_POST);, I get the other elements that were there before I dynamically added the Jquery Code, but not the file elements.

Can someone help? Thanks in advance.

[EDIT] Code added:

$(".btn_add").click(function () {
$("#file_stage").before("<tr><td>Primary <input type='radio' name='primary' value='0' /></td><td>File: <input type='file' name='file[]' size='20' /></td></tr>");

});

[EDIT] Link to Fixee: http://fixee.org/paste/uox0hqy/

Upvotes: 0

Views: 974

Answers (1)

Flatlin3
Flatlin3

Reputation: 1659

did you used an enctype while creating the form?

<form action="http://example.com/" enctype="multipart/form-data" method="post">
    <!-- your input fields -->
</form>

please note that you can access files from forms via $_FILES not via $_POST

print_r($_FILES);

EDIT (code recieved): you should add the enctype to the html form using input="file" fields (http://fixee.org/paste/uox0hqy/ - line 80)

<form method="post" action="<?php echo base_url();?>admin/content/albums/" id="new_album" enctype="multipart/form-data" name="new_album">

Upvotes: 2

Related Questions