开发者

Problem checking the name of a file in php

开发者 https://www.devze.com 2022-12-09 02:38 出处:网络
I am writing a PHP page to convert an uploaded file to XML. I only wan开发者_开发技巧t to convert the news file to XML. The only file that ever needs to be converted is news.htm. I have narrowed my pr

I am writing a PHP page to convert an uploaded file to XML. I only wan开发者_开发技巧t to convert the news file to XML. The only file that ever needs to be converted is news.htm. I have narrowed my problem down to this if statement. What is wrong with it?

$fileName = basename( $_FILES['uploaded']['name'] );

if( strcmp( $fileName, "news.htm") == 0 )
(
    //convertToXML();
)


Use curly braces around the body of the if statement, instead of parentheses:

if( strcmp( $fileName, "news.htm") == 0 )
{
    //convertToXML();
}


Try:

$fileName = basename( stripslashes( $_FILES['uploaded']['name'] ) );
0

精彩评论

暂无评论...
验证码 换一张
取 消