I have this code to get the extension of a file:
$extension = end(explode(".", $_FILES["rfile"]["name"]));
That is working fine on localhost, but when I upload online hosting, it is giving me this error:
Strict Standards: Only variables should be passed by reference in...
Why not use pathinfo (PHP >= 4.0.3
), i.e.:
$ext = pathinfo($_FILES["rfile"]["name"])['extension'];
Live PHP demo
http://ideone.com/eMpbnL
PHP end
takes an reference to a variable as argument.
http://php.net/manual/en/function.end.php
So, with strict standards enabled, you should put the result of explode
into a variable first:
$exp = explode(".", $_FILES["rfile"]["name"])
$extension = end($exp);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With