Jump to content

[SOLVED] Fatal error: Only variables can be passed by reference


dreamerdevos

Recommended Posts

I have tried a lot of things. 

 

The lines of code;

 

$file_name1=$_FILES["image"]["name"];

$ext = strtolower(end(explode('.', $file_name1)));

if($ext!="jpg"&&$ext!="jpeg"&&$ext!="png"&&$ext!="tif"&&$ext!="gif")

 

The middle line being the line that is in "error"  gets this error when trying to upload a picture, Fatal error: Only variables can be passed by reference

 

$ext = strtolower(end(explode('.', $file_name1)));

 

My guess is that it has to do with the version of php my hosting company has. 

 

 

Can anyone suggest or come up with code that would work on the latest version of php. 

 

my guess is its the end and explode that it has a problem with. 

 

Also when I change the code to just

 

$ext = strtolower('.', $file_name1);  I get an error about the '.'

 

:-\ ??? :o  any help would make my me  :D

 

The end() function requires a variable to be specified as an argument.

 

$file_name1=$_FILES["image"]["name"];

$ext = explode('.', $file_name1);

$ext = strtolower(end($ext));

...

 

See:

http://us2.php.net/manual/en/function.end.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.