Reputation:
$file_name = $_FILES['profile_image']['name'];
$file_ext = end(explode('.', $file_name)); //line 10
$file_ext = strtolower($file_ext);
$file_temp = $_FILES['profile_image']['tmp_name'];
Strict Standards: Only variables should be passed by reference in on line 10
How do I get rid of this error? Please and thank you :)
Upvotes: 5
Views: 9199
Reputation: 1
Actually, if you write $ext = end(explode('.', $filename)); for getting the file extension then "Only variables should be passed by reference" can be show in php. For this reason, try to use it two steps, like: $tmp = explode('.', $filename); $ext = end($tmp);
Upvotes: 0
Reputation: 7040
If you want the last item in the array, do this:
$arr = explode(".", $file_name);
$file_ext = $arr[count($arr) - 1];
If you're trying to just get the extension from the file, use
$ext = pathinfo($file_name, PATHINFO_EXTENSION);
Upvotes: 0
Reputation: 59699
end()
expects its parameter to be able to be passed by reference, and only variables can be passed by reference:
$array = explode('.', $file_name);
$file_ext = end( $array);
You can fix this by saving the array to a variable first, then calling end()
.
Upvotes: 15