I have a huge php file that does various things based on URL variables.
Everything works fine on my WAMP server, but when I put it on my real server the file stops working.
I have narrowed it down to one line of code. If I comment that line out, everything works just fine.
here is that line:
$ext = pathinfo(basename($_FILES['uploadedfile']['name']))['extension'];
The PHP version on my WAMP server is 5.4.12
and on my server it is 5.2.17
I can't figure out what's wrong with it.
Thanks up front, for any answers.
you can use your code like that.
$ext = pathinfo(basename($_FILES['uploadedfile']['name']));
$ext = $ext['extension'];
as the php on your real server is lower than in your wamp, and not support megration betwhen function and array, check if this can fix your problem.
You're using function array dereferencing, which was only added in PHP5.4
The reason is that you try to access the item extension directly from pathinfo(). This will work better, because it's supported in versions before PHP 5.4-
$tmpExt = pathinfo(basename($_FILES['uploadedfile']['name']));
$ext = $tmpExt['extension'];
Can you just use this instead?
$ext = pathinfo($_FILES['uploadedfile']['name'], PATHINFO_EXTENSION);