CodeIgniter - How to show error message from do_upload

codeigniter you did not select a file to upload.
the filetype you are attempting to upload is not allowed.
the upload path does not appear to be valid.
do_upload codeigniter not working
codeigniter file upload
codeigniter file upload get error
you did not select a file to upload. codeigniter 3
codeigniter registration form with image upload

i want to show the success message of a content insert on a redirect is my code of controller:-

public function do_upload($field) {
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '100000';
        $config['max_width'] = '3000';
        $config['max_height'] = '3000';

        $this->load->library('upload', $config);

        if (!$this->upload->do_upload($field)) {
            $error = array('error' => $this->upload->display_errors());

            return $error;
        } else {

            $updata =$this->upload->data();
            $data = $updata['raw_name'].$updata['file_ext'];
            return $data;


public function index() {


        if(isset($_POST['post']) && (!empty($_POST['post']) || strlen($_FILES['inputUpProfile']['name']) > 0) ){
        if(strlen($_FILES['inputUpProfile']['name']) > 0) 
        $pic = $this->do_upload('inputUpProfile');
        if ($this->input->post('post') == ''){$type="image";} else {$type="image-with-text";}

        else {$pic = ""; $type = "text"; }

            $result = $this->blog->addPost($_SESSION['user_id'], $type  , $this->input->post('post'),$pic);

when upload image big than 3000 its was show me this message

Array ( [error] =>

The filetype you are attempting to upload is not allowed.

how can i read this error in my view ??


Update :-

the error messagelike this:-

Array ( [error] =>

The filetype you are attempting to upload is not allowed.
A PHP Error was encountered

Severity: Notice

Message: Array to string conversion

Filename: mysql/mysql_driver.php

Line Number: 552
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at E:\AppServ\www\cc\ccc\application\controllers\home.php:83)

Filename: core/Common.php

Line Number: 442
A Database Error Occurred

Error Number: 1054

Unknown column 'Array' in 'field list'

INSERT INTO `events` (`ev_user_id`, `ev_type`, `ev_text`, `ev_pic`, `ev_date`) VALUES (445, 'image', '', Array, '2013-10-03 23:51:47')

Filename: E:\AppServ\www\cc\ccc\system\database\DB_driver.php

Line Number: 330

if you got error like

Array ( [error] =>
   The filetype you are attempting to upload is not allowed.

in the controller you can do like

if (!$this->upload->do_upload($field)) {
    $error = array('error' => $this->upload->display_errors());

and in the view page do something like

if($this->session->flashdata('error')){echo $this->session->flashdata('error');}

please let me know if you face any problem.

How to show error message from do_upload using codigniter, $uploaded = $this->upload->do_upload('file'); //'file' is input field name if($​uploaded) { $upload_data = $this->upload->data(); // do database  Step 3: Create View File. In last step, we need to create view file, So here create item.php view file and copy bellow code, here we will display form.

just display the error in your view, here the steps: first load session library, do it at folder config, file aoutoload.php

$autoload['libraries'] = array('session');

in the controller as you have, change this piece of code for this

  if (!$this->upload->do_upload($field)) {
    $this->session->set_flashdata( 'error_msg', $this->upload->display_errors() );
    redirect( base_url( 'your view' ) );

in your view file...

    if ( $this->session->flashdata( 'error_msg' ) ) {
        echo $this->session->flashdata('error_msg');

File Uploading Class, $error;?> <?php echo form_open_multipart('upload/do_upload');?> This is so we can show error messages in the event the user does something wrong. log_message() function is used to write log messages. This is useful when you want to write custom messages.

$pic = $this->do_upload('inputUpProfile');
$this->data['upload_error'] = $pic['error'];

Then in the view:

echo $upload_error;

CI3 Multiple file upload: Custom error message ($this->upload , But how do i customize/alter file upload error message(s)? let say i have 4 files uploads, 2 files are There is not multiple file upload library in CodeIgniter as I know of So if you have problems with this you can at any time show us your code Smile if ($this->upload->do_upload(@$field_file_name)) { I had the same problem a couple days ago. My development environment is Win8 and the website was working just fine, but when i uploaded the files to production server (Linux) was displaying a blank page.

[Solved] Curious: $this->upload->display_errors(), I'm able to do multiple uploads using the following codes (bellow). on $config (​req. var in files with ".htm" and ".txt" will not be uploaded. arrays $data[0]['error'] and arrays $data[2]['error'] should Please see my attached file showing my dump result. if ($this->upload->do_upload($field_file_name)) { Teams. Q&A for Work. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information.

File Uploading Class : CodeIgniter User Guide, This is so we can show error messages in the event the user does something like to set your own field name simply pass its value to the do_upload function:. An upload form is displayed, allowing a user to select a file and upload it. When the form is submitted, the file is uploaded to the destination you specify. Along the way, the file is validated to make sure it is allowed to be uploaded based on the preferences you set. Once uploaded, the user will

image upload on local is fine but not working on live server, code: View File: <html> <head> <title>Upload Form</title> </head> <body> <?​php echo $error;?> <?php echo form_open_multipart('upload/do_upload');?> <​form action Joined CodeIgniter Community 2009. ( Skype: insitfx ). Find Yes i have try to give absolute path but it's giving error- The upload path  Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

  • hello sir, what if multiple images are getting uploded and some non image type file is also added to the files. CI actually gives error, work fine but some files are getting uploded in this process. what should i do to check all file at first in CI?
  • $this->session->set_flashdata('error',$this->upload->display_errors()); would be just fine as well, but remember the function by default encapsulates the text with <p>..</p>, so display_errors( '', '' ) might be useful to know about.
  • Obrigado amigo.
  • You have 3 errors there 2 of which are in your model which you did not provide the code for. The first error tells you exactly what is wrong: the type of file is not allowed. This is a configuration which can be set. Please read the user guide: