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

Recommended Answers

All 3 Replies

Member Avatar for iamthwee

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

So have you tried that, with your version of php and has it worked?

Try:
$extension = explode(".", $filename);
$extension = $extension[sizeof($extension)-1];

Which should return the file extension.

give us what you have written so far.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.