Welcome Guest, Not a member yet? Register   Sign In
Invalid file types (upload xls/xlsx)
#1

Sorry for my bad english, because I speak on other language.  Angel

I have a next problem:

1. On two computers installed the same server (denwer) with same versions.
2. I copied all folder with my project and his base from one computer to another.
3. My code contains validation of mime types of uploading files (I use upload library + form validation).

PHP Code:
$config['allowed_types'] = 'txt|csv|xlsx|xls';
$this->upload->initialize($config); 


And it works excellent  Blush  , but only on first computer  Confused . On another computer (where I copied my project), it not works also. Namely, .xlsx and .xls files do not pass the validation!  Huh  I get message "Invalid file type" !

In mimes.php there are .xlsx and .xls by default

PHP Code:
'xlsx'  =>      array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet''application/zip''application/vnd.ms-excel''application/msword''application/x-zip'),
'xls'   =>      array('application/vnd.ms-excel''application/msexcel''application/x-msexcel''application/x-ms-excel''application/x-excel''application/x-dos_ms_excel''application/xls''application/x-xls''application/excel''application/download''application/vnd.ms-office''application/msword'), 


I tried upload any xlsx/xls files in other scripts, that don't use Codeigniter, and there files upload success. So I think that webserver is not guilty.

I don't understand what should I do? Please Help!!!! Huh
Reply
#2

As a first step, in your editor find the line which prints the error message
Above this line insert the following

PHP Code:
var_dump($_FILES[]);
exit; 


This will tell you what file type CI is recognising...
Also, do both machines have the same CI config?
Reply
#3

Did you change $config['base_url'] in config.php after copying?
Reply
#4

Receiving invalid xls format in your excel workbook but unable to fix this error? Well you can fix this by trying manual as well as automatic solution. For manual solution you must try these steps:

Firstly you need to change the File Extension of Your Excel Sheet. Sometimes, the problem is occurred due to the unsupported file extension of your excel file. To check the support of xlsx extension, go to the ‘My Computer’. Browse ‘Tools >> Folder Options >> File Types’. Make sure that the ‘xlsx’ extension is included there or not. If not then rename this file and change ‘.xlsx’ to ‘.xls’.

Use Open and Repair option of excel:

For this, just open the Excel workbook and then go to ‘File >> Open option. Choose the file which you want to open but don’t make double tap on it. After then go to the ‘Open’ dialog box and then select ‘Open and Repair’ option from there. This process will fix the corrupt excel spread sheet and open it normally.
The chances are very less for the perfect conversion, but yes your damaged file could be recovered of course for sure.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB