php - Codeigniter $_FILES not getting all files uploaded -
i have form allows users add more 1 file cloning file input. however, when submit form , use 'print_r($_files)' doesn't show of files have added, first.
html:
<form action="admin/admin_area/save_personnel" method="post" enctype="multipart/form-data" id="add_personnel"> <div class="certificates_list"> <input type="file" name="user_certificates[]" /> <input type="text" name="certificate_name[]" class="right"/> <input type="text" name="expiry_date[]" class="expiry_date" /> </div> <div id="certificates_new"></div> <p><button type="button" id="add_certificate">add certificate</button></p> </form> jquery:
$(function() { $('#add_certificate').click( function(event){ event.preventdefault(); var clone = $('.certificates_list:first').clone(true).appendto('#certificates_new'); clone.find("input").val(""); clone.find(".expiry_date").datepicker('destroy').removeclass('hasdatepicker').removeattr('id').datepicker({ dateformat: 'dd-mm-yy', yearrange: '1900', changemonth: true, changeyear: true }).attr('name', 'expiry_date[]'); $(":input").each(function (i) { $(this).attr('tabindex', + 1); }); }); });
if upload 3 files , print_r($_files) following showing 1 file
array ( [name] => array ( [0] => license.txt ) [type] => array ( [0] => text/plain ) [tmp_name] => array ( [0] => c:\wamp\tmp\php42b1.tmp ) [error] => array ( [0] => 0 ) [size] => array ( [0] => 2496 ) ) why picking 1 of files , not of them? have done similar stuff in past , haven't had problems until now. appreciated!
var_dump of $_files['user_certificates] gives me (after uploaded 3 files)
array (size=5) 'name' => array (size=1) 0 => string 'license.txt' (length=11) 'type' => array (size=1) 0 => string 'text/plain' (length=10) 'tmp_name' => array (size=1) 0 => string 'c:\wamp\tmp\phpe11.tmp' (length=22) 'error' => array (size=1) 0 => int 0 'size' => array (size=1) 0 => int 2496
hi i've created , tested this. works expected me! :)
document: 16562761.php
<?php if (!empty($_post)) { var_dump($_files);exit; } ?> <html> <head> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script> </head> <body> <form action="" method="post" enctype="multipart/form-data" id="add_personnel"> <div id="certs_container"></div> <p><button type="button" id="add_certificate">add certificate</button></p> <p><button type="submit" id="submit">submit</button></p> </form> <div style="display: none;" id="cloner"> <div class="certificates_list"> <input type="file" name="user_certificates[]" /> <input type="text" name="certificate_name[]" class="right"/> <input type="text" name="expiry_date[]" class="expiry_date" /> </div> </div> <script type="text/javascript"> function add_clone() { var clone = $('#cloner').html(); $('#certs_container').append(clone); } $(function() { add_clone(); $('#add_certificate').click(function(e){ add_clone(); e.preventdefault(); }); }); </script> </body> </html>
Comments
Post a Comment