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
Related
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 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.
Im moving un-zipped files to a server directory /zip/file.unzipped.png
now i need to take that file and zip it.
Is it possible to do that or a need the zip archive as codeigniter guide says?
How can i do that?
Is what you're looking for just a straight download, and not saving the archive on disk before download?
If this is the case you can do what #zer02 suggested, but remove the archive step.
$name = 'mydata1.txt';
$data = 'A Data String!';
$this->zip->add_data($name, $data);
// Write the zip file to a folder on your server. Name it "my_backup.zip"
$this->zip->archive('/path/to/directory/my_backup.zip');
// Download the file to your desktop. Name it "my_backup.zip"
$this->zip->download('my_backup.zip');
The zip library should gather up all the data you've added to the zip cache in memory, and create a file to download dynamically.
Please read the user manual: http://codeigniter.com/user_guide/libraries/zip.html
There are two functions that jump out me for your use case:
$this->zip->read_file()
Permits you to compress a file that already exists somewhere on your
server. Supply a file path and the zip class will read it and add it
to the archive:
$this->zip->read_dir()
Permits you to compress a folder (and its contents) that already
exists somewhere on your server. Supply a file path to the directory
and the zip class will recursively read it and recreate it as a Zip
archive. All files contained within the supplied path will be encoded,
as will any sub-folders contained within it.
$name = 'mydata1.txt';
$data = 'A Data String!';
$this->zip->add_data($name, $data);
// Write the zip file to a folder on your server. Name it "my_backup.zip"
$this->zip->archive('/path/to/directory/my_backup.zip');
// Download the file to your desktop. Name it "my_backup.zip"
$this->zip->download('my_backup.zip');
Zip Lib CI
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.
I need to zip non-empty folder with all files and sub-folders. I found lots of classes and functions, but all of them zip whole directory structure or something like that. But I need to zip only the content of given folder.
In advance thanks for answers