[SOLVED] Import Excel File

I have a Control Form to upload Excel files. That has always worked. Now it doesn’t work in the development environment. I upload it to the host and it works.

I get the following message.

I still had to change permissions on an Excel file, even when I was developing it. I once changed all permissions of the file to full access, also copied to another location, unfortunately without success!

As I said, it works in production!!

Check Document Path in Settings

It Has to exists in the development environment.

thanks a lot, problem solved!

How did you solve this issue ?
you placed for example in the settings application
C:\Program Files\NetMake\v9-php73\wwwroot\scriptcase\tmp

And then in order to read the file you did on the onValidate:
$file = "C:\Program Files\NetMake\v9-php73\wwwroot\scriptcase\tmp".DIRECTORY_SEPARATOR .{select_file} ???

I have a field to upload the file, if the document path doesn’t exist then it won’t find the file. I adjusted the path and it worked!

to import the file I have a blank application “onExecute”

Under Linux you have to specify the full path, like this: /home/user/public_html/app/_lib/file/doc

You also need the file/doc and tmp directory permission to 0755 or 0777 depending of your setup

Yes i agree. Can you provide me with an example on localhost ?

For example this is where the file documents are being uploaded C:\Program Files\NetMake\v9-php73\wwwroot\scriptcase\tmp

And here is my blank app C:\Program Files\NetMake\v9-php73\wwwroot\scriptcase\app\program\blank_2

How can i read the file for example ??
fopen("C:\Program Files\NetMake\v9-php73\wwwroot\scriptcase\tmp".DIRECTORY_SEPARATOR.{fileName}, "r");

Don’t forget that the path of the file is not the same in dev and prod. Also this is the temp directory, your file is also loaded in file\doc with its real name

The get the path of the file use $path = $this->Ini->path_doc;

fopen($path.DIRECTORY_SEPARATOR.{fileName}, "r");

I tried it but still same error… In the production env works fine.
I tried:

$path = $this->Ini->path_doc;
$file = $path.DIRECTORY_SEPARATOR.{select_file};
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file);
$objWorksheet = $spreadsheet->getActiveSheet();

Are you using php 8.1 or 7.3

If you are using php 8.1, your path is probably wrong and still point to your php 7.3 SC

Add this in case it’s your problem: $file = str_replace(“v9-php73”,“v9-php81”,$file);

I am using php 7.3
So my path is correct C:\Program Files\NetMake\v9-php73\wwwroot\scriptcase\tmp

It should be C:\Program Files\NetMake\v9-php73\wwwroot\scriptcase\file\doc

In the tmp directory your file name will be name SC_xxxxxxxx_filename

yes exaclty, but how can i read the file afterwards in order to load in:

$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($myFileHere)

I am doing it this way

		$inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($file);
		$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
			$spreadsheet = $reader->load($file);
		} catch (\PhpOffice\PhpSpreadsheet\Reader\Exception $e) {
    		die('Error loading file: '.$e->getMessage());
		$sheetCount = $spreadsheet->getSheetCount();
		$data = $spreadsheet->getActiveSheet()->toArray();
		$worksheet = $spreadsheet->getActiveSheet();
		$highestRow = $worksheet->getHighestRow();
		$highestColumn = $worksheet->getHighestColumn();