In the Import Assistance module any (Products, Third Parties, etc) of the excel import template files I try to download will not open due to the following error:
“Excel cannot open the file ‘Example_of_import_file_produit_1.xlsx’ because the file format of file extension is not valid. Verify that the file had not been corrupted and that the file extension matches the format of the file”
If I open the file in a text editor I see the following:
<br />
<b>Warning</b>: tempnam(): open_basedir restriction in effect. File(C:\WINDOWS\TEMP) is not within the allowed path(s): (c:/dolibarr) in <b>C:\dolibarr\www\dolibarr\htdocs\core\modules\import\import_xlsx.modules.php</b> on line <b>182</b><br />
<br />
<b>Warning</b>: ZipArchive::open(): Empty string as source in <b>C:\dolibarr\www\dolibarr\htdocs\includes\phpoffice\phpexcel\Classes\PHPExcel\Writer\Excel2007.php</b> on line <b>239</b><br />
<br />
<b>Warning</b>: ZipArchive::open(): Empty string as source in <b>C:\dolibarr\www\dolibarr\htdocs\includes\phpoffice\phpexcel\Classes\PHPExcel\Writer\Excel2007.php</b> on line <b>240</b><br />
<br />
<b>Fatal error</b>: Uncaught exception ‘PHPExcel_Writer_Exception’ with message ‘Could not open for writing.’ in C:\dolibarr\www\dolibarr\htdocs\includes\phpoffice\phpexcel\Classes\PHPExcel\Writer\Excel2007.php:241
Stack trace: #0 C:\dolibarr\www\dolibarr\htdocs\core\modules\import\import_xlsx.modules.php(184): PHPExcel_Writer_Excel2007->save(false) #1 C:\dolibarr\www\dolibarr\htdocs\imports\class\import.class.php(217): ImportXlsx->write_footer_example(Object(Translate)) #2 C:\dolibarr\www\dolibarr\htdocs\imports\emptyexample.php(88): Import->build_example_file(‘xlsx’, Array, Array, ‘produit_1’) #3 {main}
thrown in <b>C:\dolibarr\www\dolibarr\htdocs\includes\phpoffice\phpexcel\Classes\PHPExcel\Writer\Excel2007.php</b> on line <b>241</b><br />
Thanks for posting. You have posted your issue in the Bugs on a stable version section.
Kindly post (here) your Dolibarr setup environment as suggested in [url]www.dolibarr.org/t/post-guidelines/16873/1 This will greatly help the community in assisting you where possible.
The problem is for the import, your serveur php need to create a temporary file.
He tries to do it but your configuration does not allow to create a file in that folder : open_basedir restriction in effect. File(C:\WINDOWS\TEMP)
While reviewing Projects - Overview, under “List of time consumed on tasks of project”, I have also encountered another similar error:
Warning: is_dir(): open_basedir restriction in effect. File(/TK1810-0001) is not within the allowed path(s): (c:/dolibarr) in C:\dolibarr\www\dolibarr\htdocs\core\lib\files.lib.php on line 101
Line 101 within “files.lib.php” reads as follows:
if (! is_dir($newpath)) return array();
It seems to me there is a privilege not set correctly somewhere that is preventing Dolibarr from writing necessary files.
Do you read what I have put above ?
You have a problem of temporary directory in php configuration
Open the php.ini and check :
Find the directive upload_tmp_dir: uncomment the line and change its value to a required path. In this example it is “/var/tmp”:
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
upload_tmp_dir = /var/tmp
Additionally for PHP versions 5.5 and greater, find the directive sys_temp_dir: uncomment the line and change its value to a required path. In this example, it is “/var/tmp”:
; Directory where the temporary files should be placed.
; Defaults to the system default (see sys_get_temp_dir)
sys_temp_dir = “/var/tmp”
Now, add the new path (in our example it is “/var/tmp”) to open_basedir of all domains, so that PHP scripts can access this directory. Use this KB article for assistance.
Note: The record to be added to the php.txt file should be:
For fixing this error I have tried file extension changing method and it worked.
I have listed the down the completed steps to perform this task. So you can also try that because you are also facing excel file extension error.