1

How do I unzip a 5GB zip file on my web server without PHP timeout?

I need to unzip a 5GB zip file on server.

When I run the unzip it times out because the file extraction takes too long.

I do not have access to shell console, all I have is a FTP and I can execute PHP by accessing the PHP file in my web browser.

How do I unzip the large file?

$dirName = $_POST["dirName"];
echo  "$dirName<br>\n";
$dirName = htmlspecialchars($dirName);

echo "$dirName<br>\n";
flush();

$zipFileName = getcwd() . "/$dirName/aTest.zip";
$destDirName = getcwd() . "/$dirName/aTest";

echo "Zip file is $zipFileName<br>\n";
echo "Directory is $destDirName<br>\n";
flush();

// Unzip selected zip file
$zip = new ZipArchive;
$res = $zip->open($zipFileName);

if ($res === TRUE) {
    // Extract file
    $zip->extractTo($destDirName);
    $zip->close();
}
echo "Successfull<br>\n";
flush();

I found an answer here but the link ("try PclZip") does not work.

following is the restrictions as per PHP Info

disable_functions 

exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,
proc_open,ini_alter,dl,popen,popen,pcntl_exec,socket_accept,socket_bind,
socket_clear_error,socket_close,socket_connect,socket_create_listen,
socket_create_pair,socket_create,socket_get_option,socket_getpeername,
socket_getsockname,socket_last_error,socket_listen,socket_read,
socket_recv,socket_recvfrom,socket_select,socket_send,socket_sendto,
socket_set_block,socket_set_nonblock,socket_set_option,socket_shutdown,
socket_strerror,socket_write,stream_socket_server,pfsockopen,
disk_total_space,disk_free_space,chown,diskfreespace,getrusage,
get_current_user,set_time_limit,dl,leak,listen,chgrp,link,symlink,
dlopen,proc_nice,proc_get_stats,proc_terminate,shell_exec,sh2_exec,
posix_getpwuid,posix_getgrgid,posix_kill,ini_restore,mkfifo,dbmopen,
dbase_open,filepro,filepro_rowcount,posix_mkfifo,_xyec,mainwork,
get_num_redirects,putenv,geoip_open,sleep,imap_open
mck
  • 23
  • 7
  • Does this answer your question? [Prevent timeout during large request in PHP](https://stackoverflow.com/questions/3909191/prevent-timeout-during-large-request-in-php) – Vinay May 17 '20 at 06:49

1 Answers1

0

You can try to change max-execution-time value with

<?php
ini_set('max-execution-time', 600); // 600 seconds

If it's not working, you should ask to the administrator of the server.

  • I am on a Free Web Hosting plan which does not allow to change settings or asking the administrator. – mck May 16 '20 at 21:51
  • Doing this on a free hosting plan bodes all sorts of trouble. Be sure to check their TOS and AUP. – Markus AO May 16 '20 at 22:24