简体   繁体   English

在php中检查文件名时出现问题

[英]Problem checking the name of a file in php

I am writing a PHP page to convert an uploaded file to XML. 我正在写一个PHP页面,将上传的文件转换为XML。 I only want to convert the news file to XML. 我只想将新闻文件转换为XML。 The only file that ever needs to be converted is news.htm. 唯一需要转换的文件是news.htm。 I have narrowed my problem down to this if statement. 我已将问题缩小到该if语句。 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语句的主体周围使用花括号,而不是括号:

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

尝试:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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