我需要将大文件上传到我的服务器(最多100mb文件)
memory_limit = 30M
post_max_size = 192M
file_uploads = On
upload_max_filesize = 192M
max_execution_time = 7200 sec
max_input_time = 7200 sec
这些是我的服务器详细信息我正在使用apache 2.2.21所以我更改LimitRequestBody上传文件夹支持2GB当我上传80 MB文件时它将无法上传当我上传10 MB文件成功上传所以任何想法上传大< / p>
感谢您提前
答案 0 :(得分:0)
如果上传“登录”的人,您还应该检查session.gc_maxlifetime
答案 1 :(得分:0)
要上传大文件(> 5MB),我使用卡盘上传方法。
/**
* @param $file
* @param $fileSize
* @param $name
* @return int
*/
public function chunkUpload($file, $fileSize, $name) {
$targetFile = 'upload/'. $name;
$chunkSize = 256; // chunk in bytes
$uploadStart = 0;
$handle = fopen($file, "rb");
$fp = fopen($targetFile, 'w');
# Start uploading
try {
while($uploadStart < $fileSize) {
$contents = fread($handle, $chunkSize);
fwrite($fp, $contents);
$uploadStart += strlen($contents);
fseek($handle, $uploadStart);
}
fclose($handle);
fclose($fp);
return 200;
} catch (\Exception $e) {
return 400;
}
}