0

I'm getting this error:

Strict standards: Only variables should be passed by reference in C:\wamp\www\lions\admin\UploadmemberHandler.php on line 3

Code:

$extension1 = end(explode(".", $_FILES["addmemberFile"]["name"])); 

How to fix this error?

Amal Murali
  • 75,622
  • 18
  • 128
  • 150

1 Answers1

2

The function end() expects its parameter to be passed by reference, and in PHP, only variables can be passed by reference. You can easily fix this by storing the array in a variable and calling end() with that.

$arr = explode(".", $_FILES["addmemberFile"]["name"]);
$extension1 = end($arr); 

Even better, use the function which is specifically built for retrieving the file extension, pathinfo():

$extension1 = pathinfo($_FILES["addmemberFile"]["name"], PATHINFO_EXTENSION);
Amal Murali
  • 75,622
  • 18
  • 128
  • 150