PDA

View Full Version : [CodeIgniter] ko lấy được giá trị form_open_multipart



saimoto
18-10-2010, 10:32
Giả sử ta có form nằm trong "application/view":



<?

echo form_open_multipart('system/manage_add');

<div class="add_news">
<p>Hình đại diện:</p>
<input type="file" name="userfile" id="userfile">
</div>
<div style="height:20px; " class="add_news" align="center">
<?=form_submit('add','Thêm')?>
<?=form_reset('reset','Nhập lại')?>
</div>
<?=form_close();?>


Và trong system.php trong "application/controller":



function manage_add(){

if( $this->input->post('userfile'))

$dt=$this->do_upload(90,60);

}


Tức là khi có tên file thì mới gọi hàm upload còn không thì sẽ không gọi hàm upload. nhưng khi em echo cái "$this->input->post('userfile')" thì ra giá trị rỗng.

Các bạn biết lấy cái giá trị của $this->input->post('userfile') thì chỉ dùm mình chút, mình cảm ơn nhiều