duanfen9983 2015-11-25 09:13
浏览 25

使用php检查文件是否是kml文件

I am using move_file_upload on my server side in php so that client can allow users to upload their kml files to the server. I know that in order to check an image , in php I can use $check = getimagesize(file) but what would be the equivalent for a kml file check ?

I donot want to just check the extension of the file. I wish to know if infact the file is a valid kml file or not. If I only check the extension, someone can just post some other malicious file and change its extension to .kml

  • 写回答

2条回答 默认 最新

  • dpfwhb7470 2015-11-25 09:16
    关注

    If you want to see if the file has the extension KML, you can use:

    $filename = $_FILES["file"]["name"]; //or however you are getting the filename
    $ext = end((explode(".",$filename)));
    
    if($ext!="kml"){
        //Extension is incorrect
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64