! Codeigniter cannot call PHPExcel

Source: Internet
Author: User
Urgent help! Codeigniter cannot call PHPExcel. I am a beginner in Codeigniter. I used the file upload class to upload csv or excel files. at the same time, I used PHPExcel to read the content and load it into the database. My program is as follows: controllers/products. php file: & nbsp urgent help! Codeigniter cannot call PHPExcel
I am a beginner in Codeigniter. I used my file Upload class to upload csv or excel files. at the same time, I used PHPExcel to read the content and load it into the database. My program is as follows:
Controllers/products. php file:

$ Memsn = $ this-> session-> userdata ('memsn ');
$ This-> load-> library ('Excel _ Read_Operat ');
$ Groups = array ('purchaser ', 'Salesman', 'Viewer', 'merchant ');
If ($ this-> ion_auth-> in_group ($ groups ))
{
$ This-> session-> set_flashdata ('message', $ this-> lang-> line ("access_denied "));
$ Data ['message'] = (validation_errors ()? Validation_errors (): $ this-> session-> flashdata ('message '));
Redirect ('module = products', 'refresh ');
}

$ This-> form_validation-> set_rules ('userfile', $ this-> lang-> line ("upload_file"), 'xss _ clean ');

If ($ this-> form_validation-> run () = true)
{
If (isset ($ _ FILES ["userfile"]) {
$ This-> load-> library ('upload _ photo ');

$ Dest_dir = 'uploads/'. $ memsn .'/';

$ This-> dest_dir_fortest = $ dest_dir;

If ($ this-> upload_photo-> direct_is_exists ($ dest_dir )){

} Else {
Redirect ("module = products & view = upload_csv", 'refresh ');
}

$ Config ['upload _ path'] = $ dest_dir;
$ Config ['allowed _ types'] = 'csv | xls | xlsx ';
$ Config ['max _ size'] = '000000 ';
$ Config ['overwrite'] = TRUE;

$ Old_file_name = $ _ FILES ["userfile"] ["name"];
$ New_file_name = $ this-> getSystemTime (). $ _ FILES ["userfile"] ["name"];
$ Config ['File _ name'] = $ new_file_name;

// Initialize
$ This-> upload_photo-> initialize ($ config );

If (! $ This-> upload_photo-> do_upload ()){

// Echo the errors
$ Error = $ this-> upload_photo-> display_errors ();
$ This-> session-> set_flashdata ('message', $ error. $ dest_dir );
Redirect ("module = products & view = upload_csv", 'refresh ');
}


If ($ this-> upload_photo-> file_ext = '.csv '){

$ Csv = $ this-> upload_photo-> file_name;


Excel_Read_Operat: initialized ($ dest_dir. $ new_file_name );


$ Phpexcel_csv_arr_table = Excel_Read_Operat: GetArrTable_CVS ();


If (! Empty ($ phpexcel_csv_arr_table )){
$ Keys = array ('code', 'name', 'Category _ id', 'status', 'Description', 'decimal', 'custprice', 'length ', 'height', 'width', 'status ');
$ Final = array ();

Foreach ($ phpexcel_csv_arr_table as $ row_csv_value ){

$ Final [] = array_combine ($ keys, $ value );

Foreach ($ final as $ csv_pr ){
If ($ this-> products_model-> getProductByCode ($ csv_pr ['code']) {
$ This-> session-> set_flashdata ('message', $ this-> lang-> line ("check_product_code "). "(". $ csv_pr ['code']. "). ". $ this-> lang-> line ("code_already_exist "));
Redirect ("module = products & view = upload_csv", 'refresh ');
}

}

}

Under libraries/, there are Excel_Read_Operat.php files and Excel folders. the folders are PHPExcel. php and PHPExcel. The Excel_Read_Operat.php class is as follows:

If (! Defined ('basepath') exit ('no direct script access allowed ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.