上传宽图像返回空白


Uploading wide image returns blank

我想显示用户计算机上的任何图像,但我只保存了不太宽的图像。当我上传一张4000x3000大小的图片时,它会停止显示,并出现一个问号:(

这是上传并显示图像的两个页面的代码。

上传页面:

<form action="e-mail.php" method="post" enctype="multipart/form-data">
   Select image to upload:
  <input type="file" name="picture" id="picture">
    <input type="submit" value="Upload Image" name="submit">
     </form>

显示页面:

    <?php 
error_reporting(E_ERROR | E_PARSE); 
session_start(); 
//set session
     $filename    = $_FILES["picture"]["tmp_name"];
    $destination = "upload/" . $_FILES["picture"]["name"];  // Less wide imaged are save to "upload" whereas wider don't..
     move_uploaded_file($filename, $destination);
    $_SESSION['picture'] = $destination;
   ?> 
<html>
<head>
 <img src="<?php echo $_SESSION['picture']; ?>"/> // this code shows less wide images perfectly
</head>
  </html> 

所以我的问题是"如何将宽图像保存到"上传"文件夹?

感谢:)

您应该阅读PHP手册中关于文件上传的部分。那里有一些非常重要的信息。

问题的要点是,在php.ini或服务器配置中设置的文件上传大小有限制。默认值是2兆字节,如果您的图像是3000x4000,即12000000像素,则很有可能超过2兆字节(请在磁盘上检查其大小)。

如果您需要上传这样的图像,您必须更改服务器端的upload_max_filesize设置(php.ini或Apache配置)。