PHP FAQs about attachment Upload and decompression
Source: Internet
Author: User
PHP & nbsp; a compressed package for uploading and decompressing attachments can be decompressed. How can I rename the file while extracting the file and put it in another directory? Please kindly advise. Decompress the program $ zip & nbsp ;=& nbsp; zip_open ("/php/test/test.zip") PHP about attachment Upload and decompression
Upload a compressed package in PHP and I can unzip it.
How can I rename the file while extracting the file and put it in another directory?
Please kindly advise.
Decompress the program
$ Zip = zip_open ("/php/test/test.zip ");
If ($ zip ){
While ($ zip_entry = zip_read ($ zip )){
$ Fp = fopen ("/php/". zip_entry_name ($ zip_entry), 'w ');
If (zip_entry_open ($ zip, $ zip_entry, "r ")){
$ Buf = zip_entry_read ($ zip_entry, zip_entry_filesize ($ zip_entry ));
Fwrite ($ fp, '$ buf ');
Zip_entry_close ($ zip_entry );
Fclose ($ fp );
}
}
Zip_close ($ zip );
}
Add the rename function in the middle and save it to another directory ..... Share:
------ Solution --------------------
Aren't you already in another directory? "/Php/". zip_entry_name ($ zip_entry)
If you want to replace the files in the package during decompression, at least you have to give a name change rule or a new and old name table?
------ Solution --------------------
Zip_entry_name ($ zip_entry) is the file name in the package.
You can use the string function to process the object name.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service