PHP上传大图片出错,小尺寸图片工作正常[重复]

uqdfh47h  于 2023-06-20  发布在  PHP
关注(0)|答案(1)|浏览(95)

此问题已在此处有答案

upload large files using php, apache(5个答案)
5天前关闭。
大家好,我使用的代码从w3school php fileupload,但当上传一些图像,大于2000+ kb,出来的错误。上传小尺寸照片可以。
有谁知道是什么问题吗?
我检查了代码,有文件大小限制的条件,但还没有达到那里,代码是死的。

在此处测试或查看代码>>>示例

  1. html
  2. <form action="upload.php" method="post" enctype="multipart/form-data">
  3. Select image to upload:
  4. <input type="file" name="fileToUpload" id="fileToUpload">
  5. <input type="submit" value="Upload Image" name="submit">
  6. </form>
  1. php
  2. // Check if image file is a actual image or fake image
  3. if(isset($_POST["submit"])) {
  4. echo "<pre>";
  5. var_export($_FILES['fileToUpload']);
  6. echo "</pre>";
  7. $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); //get error at here
  8. if($check !== false) {
  9. echo "File is an image - " . $check["mime"] . ".";
  10. $uploadOk = 1;
  11. } else {
  12. echo "File is not an image.";
  13. $uploadOk = 0;
  14. }
  15. }
eivgtgni

eivgtgni1#

尝试检查php.ini,搜索upload_max_filesize,检查文件大小是否大于您需要的大小。默认值通常较小。

相关问题