所以我在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
谢谢。
答案 0 :(得分:0)
我该回答我自己的问题了,所以事实证明,这是我从各地编写/复制的上载脚本中的几行代码。
$max_file_size = 20000000;
if ($_FILES['files']['size'][$f] > $max_file_size) {
结果证明,这里的['files']['size'][$f]
比$max_file_size.
大得多
甚至设置为 20000000 。
无论如何,感谢您的帮助。