Trying to read the file name of a file that is uploaded as part of a form. The print_r command that I'm using to test just shows a blank screen. I have read the manual (near the bottom here) pertaining to this and don't understand what I'm doing wrong.
Controller:
public function do_upload() {
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|txt|pdf|xlsx|csv|xls|bmp';
$config['max_size'] = 1000;
$this->load->library('upload', $config);
$file_name = $this->upload->data('file_name');
print_r($file_name);
View:
<?php echo form_open_multipart('Corpmuns/do_upload', array('method' => 'post'));?>
... // some drop-down menus and text fields here
<INPUT TYPE="file" NAME="userfile" id="userfile" >
</form>
You didn't do the upload action so the file was not uploaded yet. That's why you can't get the uploaded file's name. Because it does not exists. Code $this->upload->do_upload('userfile')
and make sure the file is uploaded successfully before you get the filename.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments