0

Strict Standards: Only variables should be passed by reference in please

if(isset($_FILES['image'])){
  $errors= array();
  $file_name = $_FILES['image']['name'];
  $file_size =$_FILES['image']['size'];
  $file_tmp =$_FILES['image']['tmp_name'];
  $file_type=$_FILES['image']['type'];
  $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));

  $expensions= array("jpeg","jpg","png","docx","pdf");

  if(in_array($file_ext,$expensions)=== false){
     $errors="<div align='center'><font color='red'>extension not allowed, please choose a JPEG or PNG file.</font></div>";
  }
  • 1
    You should replace this `explode('.',$_FILES['image']['name']))` with a variable – smarber Mar 01 '17 at 10:03
  • 4
    Possible duplicate of [Only variables should be passed by reference](http://stackoverflow.com/questions/4636166/only-variables-should-be-passed-by-reference) – Vamsi Krishna B Mar 01 '17 at 10:05

1 Answers1

0

The built-in end expects an array passed by reference. So the passed array has to be a variable.

  $var = explode('.',$_FILES['image']['name']);
  $file_ext=strtolower(end($var));

This means you must pass it a real variable and not a function returning an array

smarber
  • 4,829
  • 7
  • 37
  • 78