我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

如何删除小于特定大小的图像文件?

I want delete files less than a particular size say 10kb. how do I do it in PHP??

Like so, for example:

foreach (glob('/path/to/files/*') as $file) {
    if (is_writable($file) && filesize($file) < (1024 * 10)) {
        unlink($file);
    }
}

To check size of file you need use this link. Here you got how list files in directory. Here you got documentation of readdir.

Using those links should help you.

Hope this might help:

<?php
  // outputs e.g.  somefile.txt: 1024 bytes

  $filename = 'somefile.txt';
  if(filesize($filename) == (10*1024)){
     unlink($filename);
  }
?>

近期文章

  • 从数据库中拉出以前看不见的记录
  • 使用CakePHP中的“已删除”列
  • 将字符串添加到数组中的所有但最后一项
  • 如何从<select>下拉列表中隐藏“无”值?
  • 使用php创建动态附件
  • PHP正则表达式匹配字母数字字符串与一些(但不是全部)标点符号
  • 如何输出JOINed表? [重复]
  • 如何在PHP中打开浏览器?
  • 如何使用内部加入与学说1.2?
  • 通过组合变量的名称输出变量
  • PHP对象属性声明错误
  • jquery验证和php验证码问题
  • 在其他函数可访问的函数内部创建变量?
  • 如何在DHTML中设置非标准语言
  • 如果IP地址已经在数据库中,则很简单
  • 在flash中显示JSON
  • 获取php文件值
  • 使用PHP从图像中提取alt和/或title属性
  • PHP函数不返回null但也不返回任何内容
  • 建议用PHP组织这个?

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华