Codeigniter can't read file name of uploaded file

David

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>
aszx0413

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

changed name of uploaded file in codeigniter to random string

From Dev

Uploaded file can't be accessed

From Dev

Codeigniter File Doesn't get Uploaded

From Dev

Codeigniter multiple upload with different area name and rename the file before uploaded

From Dev

Get the name of an uploaded file

From Dev

can't move_uploaded_file to folder

From Dev

PHP I can't delete uploaded file

From Dev

How can read file with unreadable file name?

From Dev

PHP file upload Issues - Can't Move uploaded File

From Dev

read_file didn't work codeigniter

From Dev

how can I read from an uploaded text file

From Java

Python says it can't find the file I am trying to rename even though it can read the file name

From Dev

How can I hide name of file uploaded using <p:fileUpload/>

From Dev

How to Read Contents of an Uploaded File

From Dev

Jersey: read uploaded file as JSON

From Dev

Read uploaded JSON file in Rails

From Dev

Can't Read *.ttf File

From Dev

Can't Read *.ttf File

From Dev

Can't read json file

From Dev

can't read a file in python

From Dev

How to get uploaded file name?

From Dev

file uploaded with name in python django

From Dev

Getting field name of uploaded file

From Dev

Can't delete a file with a '?' in the file name

From Dev

PHP CodeIgniter: File doesn't get uploaded fast enough and it continues the process without the file

From Dev

Django: Display File Name for Uploaded File

From Dev

Accessing original name of file uploaded as a file parameter

From Dev

Read a file in CodeIgniter Controller

From Dev

Convert uploaded pdf file to jpg in codeigniter