可能是 Xamp 或脚本错误?

Possible Xamp or script error?

第一次上传图片遇到这个错误。图片为 .jpg。脚本对我来说似乎没问题。所以我认为问题出在 xamp server?

Warning: imagecreatefrompng(): 'C:\xampp\tmp\phpB42E.tmp' is not a
valid PNG file in C:\xampp\htdocs\phphph\check_image.php on line 66
The file you uploaded was not a supported filetype

我在 google 上搜索但没有找到有用的东西。所以这是脚本的一部分。

 switch ($type){
   case IMAGETYPE_GIF:
        $image = imagecreatefromgif($_FILES['uploadfile']['tmp_name']) or 
        die ('The file you uploaded was not a supported filetype');
        $ext = ' .gif';
        break;
   case IMAGETYPE_JPEG:
        $image = imagecreatefromjpeg($_FILES['uploadfile']['tmp_name']) or 
        die ('The file you uploaded was not a supported filetype');
        $ext = ' .jpeg';
   case IMAGETYPE_PNG:
        $image = imagecreatefrompng($_FILES['uploadfile']['tmp_name']) or 
        die ('The file you uploaded was not a supported filetype');
        $ext = ' .png';
        break;
    default:
        die('The file you uploaded was not a supported filetype.');              
   }

缺少 break

    $ext = ' .jpeg';
  /// missing break here
case IMAGETYPE_PNG:

所以你上传了一个 jpg,代码继续进入 PNG 部分,因此你的错误。

所以,不,这不是 Xamp 服务器的问题...这是 PEBKAC 错误。