I try to write an image uploader with php. But it is giving an error when I try.
Error is:
Strict Standards: Only variables
Note $file_name_encrypted
will not contain a real or matchable extension, because your appending the filename with md5:
$file_name_encrypted = $file_name."".md5(rand(1, 1000000));
e.g filename.jpg79054025255fb1a26e4bc422aef54eb4
So it will never match any in your $allowedExts
array. Fix that then:
Change that line too:
$extension = pathinfo($file_name_encrypted, PATHINFO_EXTENSION);
Or explode then pass the exploded to the end() function.
$temp = explode(".", $file_name_encrypted);
$extension = end($temp);
The way to fix this is to explode first then use that array in end.
end()
needs to get its parameter passed by reference because it manipulates internal pointer but if there is no variable reference it will not work correctly.
Try this
$array = explode(".", $file_name_encrypted);
then
$extension = end($array);