相关疑难解决方法(0)

PHP图像上传安全检查列表

我正在编写一个脚本来将图像上传到我的应用程序.以下安全步骤是否足以使应用程序从脚本端安全?

  • 使用.httaccess禁止PHP在上传文件夹中运行.
  • 如果文件名包含字符串"php",则不允许上传.
  • 仅允许扩展名:jpg,jpeg,gif和png.
  • 仅允许图像文件类型.
  • 禁止具有两种文件类型的图像.
  • 更改图像名称.
  • 上传到子目录而不是根目录.

这是我的脚本:

 $filename=$_FILES['my_files']['name'];
 $filetype=$_FILES['my_files']['type'];
 $filename = strtolower($filename);
 $filetype = strtolower($filetype);

 //check if contain php and kill it 
 $pos = strpos($filename,'php');
 if(!($pos === false)) {
  die('error');
 }




 //get the file ext

 $file_ext = strrchr($filename, '.');


 //check if its allowed or not
 $whitelist = array(".jpg",".jpeg",".gif",".png"); 
 if (!(in_array($file_ext, $whitelist))) {
    die('not allowed extension,please upload images only');
 }


 //check upload type
 $pos = strpos($filetype,'image');
 if($pos === false) {
  die('error 1');
 }
 $imageinfo = getimagesize($_FILES['my_files']['tmp_name']);
 if($imageinfo['mime'] != 'image/gif' …
Run Code Online (Sandbox Code Playgroud)

php security upload

61
推荐指数
6
解决办法
5万
查看次数

使用PHP从JPG中删除EXIF数据

有没有办法使用PHP从JPG中删除EXIF数据?我听说过PEL,但我希望有一种更简单的方法.我正在上传将在线显示的图片,并希望删除EXIF数据.

谢谢!

编辑:我没有/不能安装ImageMagick.

php exif imagemagick image-processing

19
推荐指数
5
解决办法
4万
查看次数

标签 统计

php ×2

exif ×1

image-processing ×1

imagemagick ×1

security ×1

upload ×1