I'm making a little project for somebody. Now i'm new to messing with files in php but i managed to get it to run on localhost using Mamp. Anyway, now i wanted to upload a test version online and when i'm trying to login i get the following error:
我在为某人做一个小项目。现在我对php中的文件很陌生,但是我设法让它在localhost上运行,使用Mamp。无论如何,现在我想在网上上传一个测试版本,当我尝试登录时,我得到了以下错误:
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/fcom2126/public_html/bael/admin/overview.php on line 59
I have no idea what this error means, by searching around it could be a $ missing somewhere but i can't see where. Maybe you guys can help me out?
我不知道这个错误是什么意思,通过搜索它可能会在某个地方丢失一美元,但我看不见它在哪里。也许你们能帮我一下?
if (!in_array((new SplFileInfo($_FILES['afbeelding']['name']))->getExtension(), array('jpeg', 'jpg', 'png', 'gif'))) {
exit('<p>Foute extentie. Enkel afbeeldingen toegelaten!</p>');
} else {
$path_parts = pathinfo($_FILES['afbeelding']['name']);
$_FILES['afbeelding']['name'] = $name . "." . $path_parts['extension'];
//!!! aanpassen bij UPLOAD
$img = $_SERVER['DOCUMENT_ROOT'] ."/img/rouwregister/overledenen/". $_FILES['afbeelding']['name'];
}
The if sentence is line 59, on my localhost i don't get any error but when trying it out on the web it does give me an error.
if语句是第59行,在我的localhost上,我没有得到任何错误,但是当我在web上尝试它时,它确实给了我一个错误。
Where is my fault? Thanks beforehand
我的错在哪里?事先谢谢
Pieter-Jan
Pieter-Jan
EDIT
Could it be that SPL isn't supported in my php version yet?
可能我的php版本还不支持SPL吗?
1 个解决方案
#1
3
Your localhost is running PHP5.4+ and your production server is running PHP5.3 or older. As a result you do not have access to class member access on instantiation:
本地主机运行PHP5.4+,生产服务器运行PHP5.3或更高版本。因此,您无法访问实例化的类成员访问:
So this:
所以这个:
(new SplFileInfo($_FILES['afbeelding']['name']))->getExtension()
won't work. You need to change it to:
不能工作。你需要把它改成:
$splFileInfo = new SplFileInfo($_FILES['afbeelding']['name'])
$extension = $splFileInfo->getExtension();
if (!in_array($extension, array('jpeg', 'jpg', 'png', 'gif'))) {
#1
3
Your localhost is running PHP5.4+ and your production server is running PHP5.3 or older. As a result you do not have access to class member access on instantiation:
本地主机运行PHP5.4+,生产服务器运行PHP5.3或更高版本。因此,您无法访问实例化的类成员访问:
So this:
所以这个:
(new SplFileInfo($_FILES['afbeelding']['name']))->getExtension()
won't work. You need to change it to:
不能工作。你需要把它改成:
$splFileInfo = new SplFileInfo($_FILES['afbeelding']['name'])
$extension = $splFileInfo->getExtension();
if (!in_array($extension, array('jpeg', 'jpg', 'png', 'gif'))) {