Reputation: 611
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.
Upvotes: 1
Views: 77
Reputation: 174
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.
Upvotes: 1
Reputation: 1509
Can you just use this instead?
$ext = pathinfo($_FILES['uploadedfile']['name'], PATHINFO_EXTENSION);
Upvotes: 0
Reputation: 833
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'];
Upvotes: 1
Reputation: 20250
You're using function array dereferencing, which was only added in PHP5.4
Upvotes: 3