I am creating a module that users can upload a '.xls' file and then it must be inserted in MySQL with PHP.Server is free bsd and have all permissions by now.I have tried PHPexcelReader,but it is not working.Can u suggest me something that it can do the work.
p.s.: with phpexcelreader is writing 'The filename xxxxxxx it not readable', but it IS readable and can be downloaded.
The filename is not readable? Is it possible the file was renamed and you are still using the old name?
Well I use PHPExcel and it's available at this link
PHPExcel
You might need to pass the full absolute path to the XLS file, something like this for example:
/var/www/testing.somesite.com/uploads/xxxxxxx.xls
Or just CWD to the directory which contains the file before trying to access it.
Related
I'm running a web only server (So no server access and no things like Composer or LibreOffice) and I want to convert a DOCX template to PDF. I have succesfully processed my template with PHPWord (Downloaded using php-download.com since I can't use composer), everything fine there, but when I try to use DomPDF (also downloaded through phpdownload) to convert my docx file to a PDF file, PHP throws me "Class 'Dompdf\Dompdf' not found"...
I created a seperate file to just convert an already known docx file just to exclude any environmental issues
This is my code:
require_once("includes/PHPWord/vendor/autoload.php");
$inputfile = "files/temp/offerte_Hankie-Pankie.docx";
$path = realpath(realpath(__DIR__) . '/includes/dompdf');
echo "realpath: " . $path;
\PhpOffice\PhpWord\Settings::setPdfRendererPath($path);
\PhpOffice\PhpWord\Settings::setPdfRendererName(\PhpOffice\PhpWord\Settings::PDF_RENDERER_DOMPDF);
//Load temp file
$phpWord = \PhpOffice\PhpWord\IOFactory::load($inputfile);
//Save it
$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
$xmlWriter->save('result.pdf');
Using the echo I confirmed the folder is set properly: "/home/myusername/domains/mydomain.nl/public_html/projects/pdftemplate/includes/dompdf"
So i tried parsing the subfolders "src" or "lib" without success, I tried parsing the actual autoloader file "autoload.inc.php" and didn't work either. I tried all of the above paths with and without ending "/" (Just to be sure) and still class not found... Even though I'm using exact copies of code found to be (presumably) working on the internet.
I tried finding it in the PHPWord documentation, which didn't give me any solutions. I also tried excluding PHPWord and just using DomPDF, but since DomPDF only accepts html as input, and I don't know how (And didn't want spend another hour trying that) to convert docx to HTML, this was also a dead end.
Just as a reference, here is my file structure:
Work dir
CodeIsInThisFile.php
includes
dompdf
lib
src
Autoloader.php
autoloader.inc.php
PHPWord
vendor
autoload.php
So either I messed something up in my file structure because of the manual downloads (Which seems the most likely to me), or my code is wrong (Also likely)...
First download the dompdf library using composer or using git.
Use the realpath() or try to use the absolute path for PDF rendering library.
I am using zip library to zip a folder or directory
My path structure is
$estructure = "/home/administrator/Downloads/pdf_files/"
And iam zipping folder using below code
$this->zip->read_dir($estructure);
$this->zip->archive('/var/www/');
$this->zip->download('folder_name.zip');
Now problem is when I extract compressed directory it gives full path like
/home/administrator/Downloads/pdf_files/
what I need is when I extract the zip file its should only diretcory like pdf_file,
Could any help me on that please? thanks
Ok I got answer
$this->zip->read_dir($estructure,FALSE);
ob_end_clean();
Its working fine now.
I need to extract from zip file data.zip only one file for example 188139.xml
File contains folder with more than 88000 files. But after open - it shows me 21797 files and can't open file with big index (which is truly there). But opens 1.xml, 200.xml etc.
So it looks like limitation. Is there any suggestions how to open needed file?
Looks like it a bug of library. Fixed with alternative use of execute() function.
I want to crate a zip file and download it.
So my code is as follow;
Since i am using ci zip encoding class
my folder structure is like
c:/xampp/htdocs/gallery/print/oid_1/1.jpg,2.jpg,3.jpg
My code
$path = getcwd().'/print/oid_1/';
$this->zip->read_dir($path,FALSE);
// Download the file to your desktop. Name it "my_backup.zip"
$this->zip->download('oid_1.zip');
Here is my problem,
l C:\Users\instinctclassic\Downloads\Compressed\oid_1.zip: The archive is either in unknown format or damaged so what does this means -does it means it was mistaken while making zip file or it was mistaken while downloading.For downloading mistake i have downloaded the zip file many time enough to be sure.
2 I repaired the downloaded zip file(oid_1) and extract it but the extracted folder structure is not ignored before the oid_1 folder as said in ci zip encoding class tutorial
$this->zip->read_dir($path, FALSE);
//This will create a ZIP with the folder "directory" inside, then all sub-folders stored correctly inside that, but will not include the folders /path/to/your.
3 Assuming my folder oid_1 already exists somewhere on server.
I know this question is previously asked but mine exist all the problem from making zip file to extracting.So i am sorry for this.
Thanks
Try directory path like this:
$path = getcwd().'\print\oid_1\';
this way path will be proper, because getcwd() will return you c:\xampp\htdocs\gallery
I want to create an excel file in my phalcon php app. I've downloaded PHPExcel, but I am not able to find where the PHPExcel.php file is located. Could anyone tell me where it is?
You can put the library folder (PHPExcel/Classes/) phalcon_project/app/library/.
To use the class, you must use the method of registerDirs \Phalcon\Loader
See more in create Excel file in Phalcon php framework
In the downloaded zip file PHPExcel_1.7.9_doc.zip, there is a folder called Classes, there you can find PHPExcel.php. You only need to insert the whole Classes folder and include PHPExcel.php for a correct implementation.