在學php的時候,作了一個簡單的上傳文件的demo,在上傳大文件的時候發現報以下的錯:
php
大概的意思就是:你所上傳的文件大小超過了POST的最大限制大小(8M),
如下是有道翻譯的結果警告:POST content -
length爲2110919154字節,超過了第0行未知的8388608字節的限制 「`html
<?php if(!empty($_FILES)){ $file = $_FILES["img-file"]; move_uploaded_file($file["tmp_name"],"./res/".$file["name"]);//將文件流從臨時存儲的位置移到指定的路徑 } ?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="./file_upload.php" method="post" enctype="multipart/form-data" >
<input type="file" name="img-file" id=""><br>
<input type="submit" value="上傳">
</form>
</body>
</html>
php.ini配置文件中的默認文件上傳大小爲2M, 默認upload_max_filesize =
2M,即文件上傳的大小爲2M,若是你想上傳超過8M的文件,好比20M,你必須設定upload_max_filesize =
20M。可是光設置upload_max_filesize =
20M仍是沒法實現大文件的上傳功能,你必須修改php.ini配置文件中的post_max_size選項,其表明容許POST的數據最大字節長度,默認爲8M。若是POST數據超出限制,那麼
文件上傳的其餘注意事項svg