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

W.Doch

I have a submit file code that uploads an Excel file to my server and then uses it through the function.

When doing so:

    if ($this->upload->do_upload()){
        $data = array('upload_data' => $this->upload->data());

        $filename = $data['raw_name'];
        $fullfilename = $data['orig_name'];

        $inputFileName = FCPATH."files/automation/1/$filename.xlsx";
        $inputFileNameNew = FCPATH."files/automation/1/$filename-new.xlsx";

It gives me this output:

Error loading file ".xlsx": Could not open /var/www/html/tools/files/automation/1/.xlsx for reading! File does not exist.

Where I suspect it's because it hasn't found the file because it wasn't uploaded yet. Could be?

elddenmedio

if you want to upload a file in diferents folders by user or whatever you need to do this

public function upload_f(){
    $config['upload_path']      = FCPATH . '/files/automation/' . $id . '/';
    $config['allowed_types']    = 'xls|xlsx';

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

    if( ! $this->upload->do_upload()){
        $this->session->set_flashdata('upload-no', $this->upload->display_errors());
    }
    else{
        $this->_read_file(FCPATH . '/files/automation/' . $id . '/' . $this->upload->file_name);
    }
}

private funtion _read_file( $file ){
    $this->load->library('excel');
    $this->load->library('table');

    $file               = str_replace('//', '/', $file);

    $objPHPExcel = PHPExcel_IOFactory::load($file);

    $cell_collection    = $objPHPExcel->getActiveSheet()->getCellCollection();
    $lastRow            = $objPHPExcel->getActiveSheet()->getHighestRow();

    foreach ($cell_collection as $cell) {
        $column = $objPHPExcel->getActiveSheet()->getCell($cell)->getColumn();
        $row    = $objPHPExcel->getActiveSheet()->getCell($cell)->getRow();
        $data_value = $objPHPExcel->getActiveSheet()->getCell($cell)->getValue();

        if ($row == 1) {
            $header[$row][$column] = $data_value;
        } 
        else{
            $arr_data[$row][$column] = $data_value;
        }
    }

    $this->table->set_heading('ID', 'value1', 'value2');

    for($i = 2; $i <= $lastRow; $i++){
        $_table= array($i, $arr_data[$i]['A'], $arr_data[$i]['B']);

        $this->table->add_row($_table);
    }

    echo $this->table->generate();
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Django uploaded file doesn't process

From Dev

Get the name of an uploaded file

From Dev

Codeigniter File Doesn't get Uploaded

From Dev

move_uploaded_files() doesn't move file without error

From Dev

PHP: Get name of directories which doesn't contain file “input…”?

From Dev

AJAX doesn't get data from PHP file with Jquery

From Dev

multiparty for nodejs doesn't parse any uploaded file

From Dev

How to access/get data of the file uploaded through iPhone app in PHP?

From Dev

File doesn't get uploaded in folder php

From Dev

get uploaded file size in bytes in php

From Dev

PHP file upload Issues - Can't Move uploaded File

From Dev

AVAudioRecorder doesn't write to file fast enough

From Dev

PHP move_uploaded_file() FAILS without reason

From Dev

Laravel 5 : the move() function doesn't save the uploaded image file

From Dev

Tomahawk <t:inputFileUpload> doesn't set uploaded file, it remains null

From Dev

PHP I can't delete uploaded file

From Dev

php uploaded file not visible

From Dev

How do i get the file extension of a file uploaded with php?

From Dev

File_get_contents doesn't import php?

From Dev

move_uploaded_file doesn't work in PHP

From Dev

PHP:: File successfully uploaded (but not)

From Dev

How to access/get data of the file uploaded through iPhone app in PHP?

From Dev

File doesn't get uploaded in folder php

From Dev

How to get the file URL uploaded in google drive SDK using php

From Dev

Caja dropbox extension doesn’t update when a file is uploaded

From Dev

Multipart POST request doesn't contain the file uploaded

From Dev

PHP move_uploaded_file for a directory uploaded

From Dev

Arduino can't process serial fast enough

From Dev

Codeigniter can't read file name of uploaded file

Related Related

  1. 1

    Django uploaded file doesn't process

  2. 2

    Get the name of an uploaded file

  3. 3

    Codeigniter File Doesn't get Uploaded

  4. 4

    move_uploaded_files() doesn't move file without error

  5. 5

    PHP: Get name of directories which doesn't contain file “input…”?

  6. 6

    AJAX doesn't get data from PHP file with Jquery

  7. 7

    multiparty for nodejs doesn't parse any uploaded file

  8. 8

    How to access/get data of the file uploaded through iPhone app in PHP?

  9. 9

    File doesn't get uploaded in folder php

  10. 10

    get uploaded file size in bytes in php

  11. 11

    PHP file upload Issues - Can't Move uploaded File

  12. 12

    AVAudioRecorder doesn't write to file fast enough

  13. 13

    PHP move_uploaded_file() FAILS without reason

  14. 14

    Laravel 5 : the move() function doesn't save the uploaded image file

  15. 15

    Tomahawk <t:inputFileUpload> doesn't set uploaded file, it remains null

  16. 16

    PHP I can't delete uploaded file

  17. 17

    php uploaded file not visible

  18. 18

    How do i get the file extension of a file uploaded with php?

  19. 19

    File_get_contents doesn't import php?

  20. 20

    move_uploaded_file doesn't work in PHP

  21. 21

    PHP:: File successfully uploaded (but not)

  22. 22

    How to access/get data of the file uploaded through iPhone app in PHP?

  23. 23

    File doesn't get uploaded in folder php

  24. 24

    How to get the file URL uploaded in google drive SDK using php

  25. 25

    Caja dropbox extension doesn’t update when a file is uploaded

  26. 26

    Multipart POST request doesn't contain the file uploaded

  27. 27

    PHP move_uploaded_file for a directory uploaded

  28. 28

    Arduino can't process serial fast enough

  29. 29

    Codeigniter can't read file name of uploaded file

HotTag

Archive