SiemensSEN
asked on
rename a zip archive in php
Hello,
How do I rename a ZIP archive
e.g
I have file XX.zip with 3 file F1, F2, F3. The zip file is uploaded to the server. Now I would like to rename it to my.ZIP
So the archive will be
my.zip
--F1
--F2
--F3
Thanks
How do I rename a ZIP archive
e.g
I have file XX.zip with 3 file F1, F2, F3. The zip file is uploaded to the server. Now I would like to rename it to my.ZIP
So the archive will be
my.zip
--F1
--F2
--F3
Thanks
ASKER
This just rename the top level archive. The output will be
My.zip
xx
F1
F2
F3
I would like
my.zip
F1
F2
F3
My.zip
xx
F1
F2
F3
I would like
my.zip
F1
F2
F3
So to clarify, you are NOT asking how to rename a ZIP file.
What you're really asking is how to modify the contents of a ZIP file and change the folder structure INSIDE so that F1, F2, and F3 are no longer inside the "xx" folder?
If that is the case, then there is no real way to do it without recreating the ZIP file. You should just extract F1, F2, and F3, and then create a new zip containing just the files without the xx subfolder. You can do this with the system tools zip/unzip, or there are a bunch of PHP classes out there that will help you do this.
Search phpclasses.org for "zip" and you should find a bunch of options. Just pick the one that works best for you.
What you're really asking is how to modify the contents of a ZIP file and change the folder structure INSIDE so that F1, F2, and F3 are no longer inside the "xx" folder?
If that is the case, then there is no real way to do it without recreating the ZIP file. You should just extract F1, F2, and F3, and then create a new zip containing just the files without the xx subfolder. You can do this with the system tools zip/unzip, or there are a bunch of PHP classes out there that will help you do this.
Search phpclasses.org for "zip" and you should find a bunch of options. Just pick the one that works best for you.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
<?php
rename("XX.zip","my.zip");
?>