How to fix PHP Excel export error in application system - php

Normaly in my application system i am able to export content via PHP Exel. Now i can export the .xlsx file but if i would like to open it ill get the message : Can not open file because format or filename extension is invalid.
Error Code :
Fatal error: Uncaught exception 'Exception' with message 'Could not close zip file php://output.' in
/net/myvm0364/disc1/www/pc2/application/include/847dfknsa_2434_phpExcel/PHPExcel/Writer/Excel2007.php:346
Stack trace: #0
/net/vmits0364/disc1/www/pc2/application/include/exportMember.php(188):
PHPExcel_Writer_Excel2007->save('php://output') #1 {main} thrown in
/net/myvm0364/disc1/www/pc2/application/include/847dfknsa_2434_phpExcel/PHPExcel/Writer/Excel2007.php
on line 346
Did somebody know what i have to do ?

I have seen a similar case before on my server (then I used CSV because do not solve problem). The reason is that the excel file is too large (about 40000 or 50000 records, or file size larger than 15MB), making your server can't handle, so excel file will be broken.
Example:
The file content if successfully created is 20MB, but when the file creates 15MB, your server is overload, it will stop the process here. You can still create an excel file but can't open it.
You can try creating an excel file with a capacity of about 1MB or less than, if it work the problem may not be due to your code.
Hope can help you.
So sorry because bad english.

Related

Can't download files from public folder from Laravel 5.6

I don't know what I am doing wrong here, but I can't for the life of me manage to get the download feature to work in Laravel 5.6
I have files saved to the public folder as you can see below:
On the webpage, these images show up correctly in HTML <img> tags and when I view the details of the image, it shows me that it points to https://mydomain.test/storage/LIizYnRWEqYOgTPlzTxbmuSbTMNYIFrnjLP1YWVH.png.
However, when I try and download this file from the server, I constantly get an exception error about the file not existing (for example: "data":"The file \"public\/LIizYnRWEqYOgTPlzTxbmuSbTMNYIFrnjLP1YWVH.png\" does not exist"). I have tried every combination of path string I can think of, but everything results in the same error.
I have tried using storage_path, I have tried using the original path, I've tried hard coding the path
[2022-09-08 09:58:55] local.ERROR: Failed to download media file: The file "/home/vagrant/Code/dras/storage/LIizYnRWEqYOgTPlzTxbmuSbTMNYIFrnjLP1YWVH.png" does not exist
[2022-09-08 09:59:38] local.ERROR: Failed to download media file: The file "public/LIizYnRWEqYOgTPlzTxbmuSbTMNYIFrnjLP1YWVH.png" does not exist
[2022-09-08 10:00:14] local.ERROR: Failed to download media file: The file "https://mydomain.test/storage/LIizYnRWEqYOgTPlzTxbmuSbTMNYIFrnjLP1YWVH.png" does not exist
[2022-09-08 10:17:18] local.ERROR: Failed to download media file: The file "app/public/LIizYnRWEqYOgTPlzTxbmuSbTMNYIFrnjLP1YWVH.png" does not exist
[2022-09-08 10:45:50] local.ERROR: Failed to download media file: The file "storage/public/LIizYnRWEqYOgTPlzTxbmuSbTMNYIFrnjLP1YWVH.png" does not exist
The only combination that doesn't throw an exception about "file does not exist" is when I use the path
return response()->download( 'storage/LIizYnRWEqYOgTPlzTxbmuSbTMNYIFrnjLP1YWVH.png' );
However, that command throws a totally different error:
Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Symfony\Component\HttpFoundation\BinaryFileResponse::header() in file /home/vagrant/Code/dras/app/Http/Middleware/Cors.php on line 27
The path:"public/LIizYnRWEqYOgTPlzTxbmuSbTMNYIFrnjLP1YWVH.png\ implies the conflict between windows and linux systems. There cant be both / and \ in a path. it must be either or. Unfortunately, i have been there and there is no easy way to get past this. you must use str_replace method to manually replace either (/) or () with the other. Check what your OS views as a valid file path first. it should be either: \public\LIizYnRWEqYOgTPlzTxbmuSbTMNYIFrnjLP1YWVH.png
or
/public/LIizYnRWEqYOgTPlzTxbmuSbTMNYIFrnjLP1YWVH.png
Edit: For future reference, this is what finally resolved the problem,
BinaryFileResponse in Laravel undefined

PHPExcel can't read Excel 4.0 worksheet

Have this project which aims to import an Excel sheet: the file is a report, not a flat file and there's no way to obtain such. So I'm using PHP Excel to read the file and save the data we need into the application.
Problem is that the file is in Excel 4.0 format which I can't edit (apparently), it can be opened and viewed in MS Excel application, but PHP Excel throws the exception when trying to read it with Excel5:
Fatal error: Uncaught exception 'PHPExcel_Reader_Exception' with message 'The filename C:/xampp/htdocs/uploads/PS.xls is not recognised as an OLE file' in C:\xampp\htdocs\includes\PHPExcel-1.8\Classes\PHPExcel\Shared\OLERead.php on line 90
PHP Excel identifies the file as in HTML format, but also, throws me the error:
Warning: DOMDocument::loadHTML(): Invalid char in CDATA 0x4 in Entity, line: 1 in C:\xampp\htdocs\includes\PHPExcel-1.8\Classes\PHPExcel\Reader\HTML.php on line 495
I suppose this is because the data contains special characters (UTF-8), but found nothing in PHPExcel that could change the encoding... neither could find anything about this problem and I'm starting to think there's no solution for this, except by asking the user to copy & paste the data to "decent" Excel file... That way works, but require some manual manipulation.
No it can't read it. The minimum BIFF format version that PHPExcel can read is BIFF 5 (from 1993).
Good luck finding anything capable of reading BIFF 4 (from 1992). BIFF 4 uses OLE1, while PHPExcel can only read .xls files using OLE2 (from BIFF 5 onwards). I'm not aware of any pure PHP extensions that can handle such an early format; you may need to use the commercial LibXl extension.

How to read a nonlocal excel with PHPExcel

I have the following problem, the project is that a run will be placing data in excel and these data must be on a page monitoring , the tool I'm using is the PHPExcel library works without problem, the problem is the user will have the excel on your machine and the page will be on the server so you should be able to connect to the user's computer but by placing the address the library has problems, I do not know if any other function to help me redirect , now I exercise locally and does not work.
Don't problem:
$objPHPExcel = $objReader->load("D.xlsx");
With Problem:
$objPHPExcel = $objReader->load("localhost:8081/excel/ticket/D.xlsx");
Or
$objPHPExcel = $objReader->load("10.204.8.14:8081/excel/ticket/D.xlsx");
Message:
Uncaught exception 'PHPExcel_Reader_Exception' with message 'Could not open localhost:8081/excel/ticket/D.xlsx for reading! File does not exist.' in C:\xampp\htdocs\excel\ticket\Classes\PHPExcel\Reader\Excel2007.php:347 Stack trace: #0 C:\xampp\htdocs\excel\ticket\prueba.php(15): PHPExcel_Reader_Excel2007->load('localhost:8081/...') #1 {main} thrown in C:\xampp\htdocs\libreria_excel\ticket\Classes\PHPExcel\Reader\Excel2007.php on line 347
The URL is OK.
Thank you very much and greetings!

PHP Create Tar File: PharData [PharException] "contents of file could not be written, seek failed"

I'm trying to create a tar file using PHP and I'm running into issues.
Using class PharData, ::addFile and ::buildFromDirectory both throw the same exception:
exception 'PharException' with message 'tar-based phar
"C:/Apache24/htdocs/_frames/storage/glacier/archive_cache/9.tar"
cannot be created, contents of file "MVI_4492.MOV" could not be
written, seek failed' in
C:/Apache24/htdocs/_frames/storage/glacier/cron/upload_archives.php:212
Stack trace: #0
C:/Apache24/htdocs/_frames/storage/glacier/cron/upload_archives.php(212):
PharData->addFile('C://Apache24//htd...', 'MVI_4492.MOV') #1 {main}
Thoughts?
You are running out of disk space, during operation. After it - space is restored (because tmp files are filled with data and then cleaned).
If not, then another reason is that you are using 32bit php, which does not support files larger than 2GB

Cannot upload image above 75 kb [duplicate]

This question already has an answer here:
php image upload errors [duplicate]
(1 answer)
Closed 9 years ago.
I successfully uploaded an image below 70 kb on server. manage server cpanel view already set php.ini file
max_upload =2000mb
max-exe-time = 300
max input time =600
n php.ini file everything is ok.
My problem above 70kb image can't move temp directory
i cant understand im using zend framework and java script using
Server Error log display following error
[Thu Jun 20 20:53:32 2013] [error] [client 59.164.48.115] PHP Fatal error: Uncaught exception 'Zend_Controller_Response_Exception' with message 'Cannot send headers; headers already sent in /home/indepet/application/modules/cms/controllers/ProductController.php, line 1' in /home/indepet/library/Zend/Controller/Response/Abstract.php:321\nStack trace:\n#0 /home/indepet/library/Zend/Controller/Response/Abstract.php(148): Zend_Controller_Response_Abstract->canSendHeaders(true)\n#1 /home/indepet/library/Zend/Controller/Action/Helper/Redirector.php(223): Zend_Controller_Response_Abstract->setRedirect('/index/home', 302)\n#2 /home/indepet/library/Zend/Controller/Action/Helper/Redirector.php(301): Zend_Controller_Action_Helper_Redirector->_redirect('/index/home')\n#3 /home/indepet/library/Zend/Controller/Action/Helper/Redirector.php(381): Zend_Controller_Action_Helper_Redirector->setGotoSimple('home', 'index', NULL, Array)\n#4 /home/indepet/library/Zend/Controller/Action/Helper/Redirector.php(502): Zend_Controller_Action_Helper_Redirector->gotoSimple('home', 'index', NULL, Array)\n#5 [internal fun in /home/indepet/library/Zend/Controller/Response/Abstract.php on line 321, referer: my site name
sometimes 100 and 100 above kb image file upload successfully again
i was try image upload following error show
another doubt
same code work other servers successfully im using Australia server
This error isn't related to upload size, instead Zend is trying to print headers after something has already been rendered (possibly because there's been an error and it's trying to redirect). Check for anything that may have been outputted in your view controller. White space at the end of the file is an easy one to miss - in fact, it's good practice to not use a closing PHP tag ?> at the end of the file for this reason.

Categories