Coder Social home page Coder Social logo

Comments (13)

ungenio avatar ungenio commented on July 27, 2024

I have the same problem, too. To compress a directory I'm using another script. It is fast and does not generate corrupt files.

`<?php
$the_folder = 'NAME FOLDER HERE';
$zip_file_name = "backup_".date('Y-m-d_His').".zip"; // name of the returned file

$download_file= true;
//$delete_file_after_download= true; doesnt work!!

class FlxZipArchive extends ZipArchive {
/** Add a Dir with Files and Subdirs to the archive;;;;; @param string $location Real Location;;;; @param string $name Name in Archive;;; @author Nicolas Heimann;;;; @access private **/

public function addDir($location, $name) {
    $this->addEmptyDir($name);

    $this->addDirDo($location, $name);
 } // EO addDir;

/**  Add Files & Dirs to archive;;;; @param string $location Real Location;  @param string $name Name in Archive;;;;;; @author Nicolas Heimann
 * @access private   **/
private function addDirDo($location, $name) {
    $name .= '/';
    $location .= '/';

    // Read all Files in Dir
    $dir = opendir ($location);
    while ($file = readdir($dir))
    {
        if ($file == '.' || $file == '..') continue;
        // Rekursiv, If dir: FlxZipArchive::addDir(), else ::File();
        $do = (filetype( $location . $file) == 'dir') ? 'addDir' : 'addFile';
        $this->$do($location . $file, $name . $file);
    }
} // EO addDirDo();

}

$za = new FlxZipArchive;
$res = $za->open($zip_file_name, ZipArchive::CREATE);
if($res === TRUE)
{
$za->addDir($the_folder, basename($the_folder));
$za->close();
}
else { echo 'Could not create a zip archive';}

if ($download_file)
{
ob_get_clean();
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private", false);
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=" . basename($zip_file_name) . ";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($zip_file_name));
readfile($zip_file_name);
}
?>`

It is necessary to write the name of the folder

$the_folder = 'NAME FOLDER HERE';

It would be great if this code could be incorporated into PHPFM.

from phpfm.

dulldusk avatar dulldusk commented on July 27, 2024

Thanks for the notice beccare, this is a great issue.
I have yet to test phpFileManager better on the latest php versions.
But nobody make donations to the project, so the process is very slow.
I thanks ungenio too for the code, it surely can be tested and incorporated on the script, if it is indeed a solution. Why don't you update the script and make a pull request? I will gladly test it, accept it, and then your name will be forever on the changelog as a contributor.
https://www.dulldusk.com/phpfm/changelog/

from phpfm.

atesin avatar atesin commented on July 27, 2024

sadly with this bug i cant use this software yet :( ..... copying massive files (zipped) from and to the website is an essential feature for an online file manager :(((

i tried to patch myself but i am not so skilled and is very hard to me :( .... i hope somebody will pull a patch soon, even with code above (can i subscribe?) ....

from phpfm.

arnisjuraga avatar arnisjuraga commented on July 27, 2024

Windows file system usually is case-insensitive. Linux on the other hand is case-sensitive.
So, adding files

my_images
|- image.jpeg
|- Image.jpeg 
|- image.JPEG

will have 3 "similar" filenames which are completely OK on Linux file system, but will generate error "file already exists" when extracted on Windows system.

I am not saying this is the reason in this time, but double checking zipped files might helped for anyone landing to this issue by search.

from phpfm.

atesin avatar atesin commented on July 27, 2024

in reply to @arnisjuraga , conventionally all filenames in web server document root should be lowercase

in reply to me, there are native php extensions that can be used instead: zip, bzip2, gzip

from phpfm.

atesin avatar atesin commented on July 27, 2024

hi, is there some update on this? ... i think this is a critical issue... until maybe there are others more critical i didnt read

some bug reports even come with patch... please read them and dont lose the oportunity of people that are helping to improve this good piece of software

from phpfm.

atesin avatar atesin commented on July 27, 2024

hi.... any news about this?

.... a year has passed ... is this project still alive? ... would be ashame if not, i like it so much, but this is a huge annoyance because i cant be downloading a big populated folder one file at a time... or even worse whole directory trees :(

from phpfm.

JoyBrad avatar JoyBrad commented on July 27, 2024

@dulldusk @atesin @beccare
Unfortunately, I had to spend a few days to get the downloaded zip fixed. It will be cumbersome to fix manually if the zip has many folders/files.

Fortunately, I did not do all that manually and had some time to spend so created a shell script that works like a charm and fixes the issues observed so far in the zip created by phpfm.

Code: fix-duplicate-names-in-zip.sh

Hope it helps for the time being until the issue is fixed by phpfm.

Also, the issue is still there in the latest version 1.7.9.
I might contribute to fix this in phpfm itself if I get some time.

from phpfm.

atesin avatar atesin commented on July 27, 2024

hi... thanks for your care ... 3 ideas come to my mind

  • use native php compression functions as said above (why not?)
  • make phpfm actually USE this shell script to generate the requested file temporarily and send it
    • maybe through some little patch that adds a shell_exec() as post process?
  • i forgot the third for now :/ ... but multibyte string extensions maybe has something to do

from phpfm.

JoyBrad avatar JoyBrad commented on July 27, 2024

@atesin I have not dived into the phpfm code yet, but I think it should be pretty simple to fix in php as you suggest using native functions.

I don't think it's a good idea to use the shell script as a part of phpfm. Besides, the script works only for .zip files for now. I noticed that the problem is same or similar for each of the compression methods offered by phpfm. So in that sense, a php fix might be little trickier as well. Not if someone figures out the cause of the behavior.
The script is just a workaround till the time it's fixed in phpfm, at least you can backup your contents in zip and be able to view/extract after fixing it.

Also, let me know if you tested it and if it works fine.

from phpfm.

JoyBrad avatar JoyBrad commented on July 27, 2024

By looking at the zip, the cause seems to me that the Zip file may have been created(by phpfm) without dedicated directory entries. For instance the zip tool has the option -D do not add directory entries.

from phpfm.

atesin avatar atesin commented on July 27, 2024

if the problem is similar for all compression methods, then i think all methods are managed by the same (bugged) external library.... so by dropping the external library in favor of standard ones will kill all problems at once..... additionally, "official" libraries got "official" support

from phpfm.

JoyBrad avatar JoyBrad commented on July 27, 2024

@atesin Seems like phpfm uses pack() function to write the zip as binary, and using magic numbers like 0x04034b50 for zip. and 0x02014b50 for zip_dir_magic_number.
Only someone who wrote it should and can fix it properly since I don't want to spend hours understanding and testing different scenarios to find the logical error.

Until then, going to use my shell script to fix it post-download

from phpfm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.