简体   繁体   中英

Problem checking the name of a file in php

I am writing a PHP page to convert an uploaded file to XML. I only want 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();
}

尝试:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM