I have a Symfony 2 project with an upload folder (uploads works well). I'm creating a ZIP file after the upload which I put inside the same folder as the uploaded file (so the archive is created from the PHP script).
But i cannot extract the archive afterwards under MAC OS. The error is the following ("100" beeing a folder inside the upload folder):
What does that mean in MAC OS ? I suspect this is a directory permission issue. If i move and try to extract the ZIP on my Desktop it does not work either. I don't know in which direction to look. I've noticed if i try to do the same thing on another PHP project on which i DIDN't mess with the permissions required when installing symfony, the script and ZIP extraction works...
Updates :
Folder/files permissions :
Sudo unzip result :
Any ideas ? Thanks in advance,
Got it working ! NEVER trim() a ZIP file contents before saving it somewhere on your server. It seems to corrupt the archive.
Related
I tried downloading a directory folder using wget, and it seems to have worked properly. However all the PHP files are empty. I know that they should not be empty as they show a file size on the web directory.
The folder I am trying to download is here:
https://www.isuperman.tw/wp-content/plugins/automatewoo-referrals/
I used these directions to download recursively with wget.
How to download HTTP directory with all files and sub-directories as they appear on the online files/folders list?
Any ideas on why they are downloading blank/empty?
view-source:https://www.isuperman.tw/wp-content/plugins/automatewoo-referrals/automatewoo-referrals.php
nope the files are empty, doesnt matter whats the content of the files.. if you use wget to download a file, wget simulates A browser and get the parsed php content from the server...
and these seems to be empty
if you want to download the files with php, use ftp or the server must not parse these files and deliver its raw content
I'm trying to see if a directory exists inside a ziparchive using statName and I have come across an odd quirk.
When I generate a zip file in php I add the files in this fashion: $this->zip->addFile($file, $path); where $file is C:\xampp\htdocs\images\uploads\about.png and $path is the internal path images/uploads/about.png. If I try and see if images/uploads/ exists when checking the zip in another routine using statName I get a false response even though the files and directories exist if opened by winzip.
For testing I made a new zip using winzip, and added a folder images and in and then uploads mimicking the above and checked if images/uploads/ existed using statName and it does!
I've made an output of the zip file using a loop and you can clearly see in the ziparchive created zip folder there is no verbatim images/uploads/ directory, yet there are files in those directories if you open the zip and as seen in output. Whereas the winzip one has the directory listed verbatim.
What is preventing the statName from showing up with the ZipArchive created zip file? I can only assume its because the dir is not listed verbatim, but that doesn't make any sense as those directories do exist! Is there something I don't know in the way ZipArchive handles adding files?
I cannot believe this hasn't been asked before, but I cannot find the answer on stackoverflow, please redirect me if this is a duplicate and I'm too retarded to find it.
I am creating a script that will download a kmz file from my custom google map, then will unzip it, read the xml and create a web page that lists all my markers. But I don't have access to the servers to create a writable folder so where can I download the kmz file to then unzip it?
Tried the temp folder (/var/tmp) and it seems to download the file, but I cannot work on the file afterwards or extract it, probably because the file gets deleted right after I call fclose, after downloading, as it doesn't exist anymore if I scan the directory.
UPDATE:
To answer question, the file is immediately deleted because it is a shared server and there are tons of session files in that folder that are created by all the visitors of each websites
I am new in codeigniter, even in PHP.
I want to upload a zipped folder which may contain the module of CMS including sub directories .On other hand I have to unzip the folder at server side.
Is there any way to accomplish this task?
I've ever tried to upload & unzip the uploaded zip file (that contain XML file), unzip it & extract the XML data on the server side.
I used CodeIgniter-Unzip library to unzip the uploaded zip file, it's easy to use. Here is the source
CodeIgniter-Unzip
Hope it helps :)
I have a folder with files, and at the click of a button from an application, I would like to create a zipped version of the folder. I understand that it's possible to create a tar.gz version on a UNIX system by passing in the command exec(tar -cvf foldername destination_filename).
Question: Is it possible to create a zipped file on a UNIX system? If it is possible, what's the logic/command behind it?
Most *nix systems will support the following commnad:
zip -r destination_filename.zip foldername
Use php zip extension? http://www.php.net/manual/en/class.ziparchive.php
And i guess you'll find useful classes from phpclasses too: http://www.phpclasses.org/search.html?words=zip&x=0&y=0&go_search=1
You need to pass the -z option to tar to have it also zip the file:
tar -czf foo.tar.gz foo/
Make sure you are in a place that the webserver has write privileges. For example, you may need chdir into the parent folder of the folder you wish to zip, and then get a temp file name in /tmp, and then create the command to zip to that temp file name.
It sounds like you have the rest figured out!
http://www.gnu.org/software/tar/manual/tar.html