0

I'm getting this error on my image upload script

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

Here is the script

<?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";
  }
?>

It supposedly saves a temp file and then checks if there is any duplicates, if there isn't it's supposed to save the image to "images/" I'm not sure why it's saying that only variables should be passed. Any suggestions would be greatly appreciated Thanks

Joe Mejia
  • 3
  • 1

1 Answers1

0

The end command takes a variable by reference you should perform your explode and assign it to a variable prior to calling end

$tmp = explode(".", $_FILES["file"]["name"]);
$extension = end($tmp);
Orangepill
  • 24,500
  • 3
  • 42
  • 63