PHP on the upload of attachments to unzip the problem

Source: Internet
Author: User
Tags comparison table
In PHP a compressed package upload, I have been able to unzip.
Now how to rename it while extracting it, and put it in another directory?
Please teach the great God.
Unzip 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);
}
Ask for the function in the middle plus rename and save to a directory .....


Reply to discussion (solution)

Unzip is unzip, rename is rename
Why do you rub the irrelevant stuff together?
Just do it separately.

Rename the files in the file under another directory when you unzip them.

Unzip is unzip, rename is rename
Why do you rub the irrelevant stuff together?
Just do it separately.

Didn't you put it in another catalogue? "/php/". Zip_entry_name ($zip _entry)
If you want to change the file in the package when you unzip it, at least you have to give a change name rule or a new and old name comparison table?

Understand, the name is only the first five characters and then the suffix name is not changed.

Didn't you put it in another catalogue? "/php/". Zip_entry_name ($zip _entry)
If you want to change the file in the package when you unzip it, at least you have to give a change name rule or a new and old name comparison table?

Zip_entry_name ($zip _entry) Gets the file name in the package
You do this with a string function, just generate the target file name.

Yes, thanks./ui/scripts/csdn/plugin/001/face/63.gif][/img]

I echo "Zip_entry_name ($zip _entry)" came out of an array ah .... What's going on....

  • Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.