文件大小统计失败 [英] filesize stat failed

查看:82
本文介绍了文件大小统计失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个php脚本,该脚本循环遍历指定目录中的所有文件.它为找到的每个文件返回名称,文件大小,modified_date等.该脚本会正确返回大多数文件的信息,但其中包含中文或其他符号的文件除外.然后,我得到了著名的文件大小统计失败错误(警告).在不更改文件名的情况下,我该如何解决?

I have a php script running, which loops through all files in a specified directory. It returns name, filesize, modified_date etc. for each file it finds. The script returns the info for most of the files correctly, except for the ones that have Chinese or other symbols in it. Then I get the famous filesize stat failed error (warning). How would I solve this, without changing the filenames?

如果需要,我会提供代码.

I will provide code if needed.

推荐答案

我以前遇到过这个问题;文件系统编码很难且难以预测,但这通常对我有用:

I've encountered this before; file system encoding is difficult and hard to predict, but this usually works for me:

stat(iconv('UTF-8', 'ISO-8859-1', $filename));

它只是将文件名从utf8转换为iso8859-1并尝试.

It just converts the filename from utf8 to iso8859-1 and tries.

但是,这很棘手,只需在此页面中查看帖子评论中的多汁对话框即可:

This is tricky though, just look at this page for a juicy dialog in the post comments: http://www.rooftopsolutions.nl/blog/filesystem-encoding-and-php

这篇关于文件大小统计失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆