PHP Unzip very large file
Asked Answered
E

4

6

I have a zip file on the server. It's 1.1gb made up of thousands of small files. I do not have shell or root access to the server and can only use ftp and create php files.. so far I have tried exec and shell exec but none worked. The server is running free bsd. How can I unzip the file into the directory it is in?

Execrative answered 1/6, 2013 at 22:27 Comment(3)
Could you edit php.ini? I presume unzipping it in PHP would take a while and would cause a timeout.Salangi
All I have is ftp access into the web root directory, and php is pribably running as a limited userExecrative
If you can't change the timeout, I would think just unzipping locally and sending the files unzipped over FTP to the server over night would be the easiest solution. You need the sleep anyway, right? :)Salangi
E
0

Thanks for the suggestions everyone. I ended up modifying the code in this question to unzip the files.

Unzip a file with php

Execrative answered 4/6, 2013 at 0:24 Comment(0)
Z
5

For a pure PHP solution, try PclZip - this would not require you to install any PHP extensions or require shell access - you just need to write access to wherever you want to extract the files.

Zackzackariah answered 1/6, 2013 at 22:30 Comment(0)
E
1
$filename = '/media/file.gz';

$unzipped_content = '';   
$zd = gzopen($filename, "r");
while ($zip_file = gzread($zd, 10000000)){
    $unzipped_content.= $zip_file;
}
gzclose($zd);

echo $unzipped_content;
Eurythmic answered 6/7, 2014 at 23:28 Comment(0)
E
0

Thanks for the suggestions everyone. I ended up modifying the code in this question to unzip the files.

Unzip a file with php

Execrative answered 4/6, 2013 at 0:24 Comment(0)
N
0

Add this at the beginning of your script!

// Increase the memory limit to 1024M (1 GB)

ini_set('memory_limit', '1024M');

// Increase the maximum execution time to 300 seconds (5 minutes)

set_time_limit(300);
Newhouse answered 20/8, 2024 at 16:12 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.