如何在我的Web服务器上解压一个5GB的压缩文件而不出现PHP超时?

问题描述 投票:0回答:1

如何在我的Web服务器上解压一个5GB的压缩文件而不出现PHP超时?

我需要在服务器上解压一个5GB的压缩文件。

当我运行解压程序时,由于文件提取时间太长,它超时了。

我不能访问shell控制台,我只有一个FTP,我可以通过访问我的Web浏览器的PHP文件来执行PHP。

如何解压大文件?

$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();

我找到了一个答案 此处 但链接("try PclZip")不能用。

以下是PHP信息中的限制

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
php unzip large-files
1个回答
0
投票

你可以尝试更改 最大执行时间 价值与

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

如果它不工作,你应该问服务器的管理员。

© www.soinside.com 2019 - 2024. All rights reserved.