[英]PHP Post Form, Can't upload files over 25MB
所以我在php.ini中更改了所有这些值:
最大文件上传大小= 10000M
发布上传大小= 11000M
超时最长时间= 12000
输入最大时间= 12000
我也使用一个PHP表格,一次上传多个文件:index.php(文件上传表格,页面上需要php后端的其他代码)
<input type="hidden" value="form" name="<?php echo ini_get('session.upload_progress.name'); ?>">
<div class="upload-btn-wrapper">
<button class="btn">Drag File / Click to upload</button>
<input type="file" name="files[]" multiple="multiple" id="fileToUpload">
</div>
</form>
document.getElementById("fileToUpload").onchange = function() {
startUpload();
setTimeout(function(){document.getElementById("form").submit();}, 1000);
}
</script>
再次,我可以正常上传普通文件,但大文件不起作用。 继承人文件上传php代码:
<?php
session_start();
//boi
$max_file_size = 20000000; //2GB
$path = $_SESSION["directory"]."/"; // Upload directory
$count = 0;
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST"){
// Loop $_FILES to exeicute all files
foreach ($_FILES['files']['name'] as $f => $name) {
if ($_FILES['files']['error'][$f] == 4) {
continue; // Skip file if any error found
}
if ($_FILES['files']['error'][$f] == 0) {
if ($_FILES['files']['size'][$f] > $max_file_size) {
$message[] = "$name is too large!.";
continue; // Skip large files
}
else{ // No error found! Move uploaded files
if(move_uploaded_file($_FILES["files"]["tmp_name"][$f], $path.$name))
$count++; // Number of successfully uploaded file
}
}
}
}
header("location: index.php");
?>
这个网站上的网址是: http : //simpledrive.duckdns.org/simple
谢谢。
是时候回答我自己的问题了,事实证明,在我从各处写过/写过的上传脚本中有几行代码。
$max_file_size = 20000000;
if ($_FILES['files']['size'][$f] > $max_file_size) {
原来['files']['size'][$f]
这里的massivley大于$max_file_size.
甚至设定在20000000 。
无论如何,谢谢你的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.