0

我的图片上传脚本出现此错误

SCREAM: Error suppression ignored for
( ! ) Strict standards: Only variables should be passed by reference in               C:\wamp\www\Arede\upload.php on line 14
Call Stack
#   Time    Memory  Function    Location
1   0.0003  262744  {main}( )   ..\upload.php:0

这是脚本

<?php
$allowedExts = array("gif", "jpeg", "jpg", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 2000000000000)
&& in_array($extension, $allowedExts))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br>";
    echo "Type: " . $_FILES["file"]["type"] . "<br>";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";

if (file_exists("images/" . $_FILES["file"]["name"]))
  {
  echo $_FILES["file"]["name"] . " Já Existe ";
  }
else
  {
  move_uploaded_file($_FILES["file"]["tmp_name"],
  "images/" . $_FILES["file"]["name"]);
echo "<table align=\"center\" style=\"color:#FFF\"><tr align=\"center\"><td align=\"center\">
<img src=\"wp-content/uploads/2013/05/checkmark-green-3D-small.png\" width=\"17\"     height=\"16\" /><h3 style=\"color:#FFF; font:bold;\">Upload bem sucedido</h3> 
</td>
</tr>
</table>

  ";
      }
    }
  }
else
  {
  echo "Invalid file";
  }
?>

它应该保存一个临时文件,然后检查是否有任何重复,如果没有它应该将图像保存到“images/”我不知道为什么它说只应该传递变量。任何建议将不胜感激谢谢

4

1 回答 1

0

end命令通过引用获取变量,您应该在调用之前执行分解并将其分配给变量end

$tmp = explode(".", $_FILES["file"]["name"]);
$extension = end($tmp);
于 2013-06-04T20:53:49.777 回答