缩图后的图片大小是小了的啊test folder[ad@localhost test]# ls -l
-rwxr--r-- 1 apache apache 760072  3月  3 12:45 test_742k.jpg
drwxrwxrwx 2 apache apache   4096  4月  3 16:48 upload
-rwxr--r-- 1 apache apache   1787  4月  3 16:16 upload.phptest/upload folder[ad@localhost upload]# ls -l
-rw------- 1 apache apache 4320  4月  3 16:48 test_742k.jpg
[root@localhost upload]# 把test_742k.jpg上传到test/upload/下,名称没变,大小是有变,但读取的大小是760072问题是上传及缩图后即时读取到的大小没变,如果在另一页读取缩图的大小,就会是真正的大小4320程序代码就是上面的啊,不知哪里有错

解决方案 »

  1.   

    对于file处理php是有状态缓存的,你可以用函数clearstatcache清除文件状态缓存。
    受影响的函数包括 stat(),lstat(),file_exists(),is_writable(),is_readable(),is_executable(),is_file(),is_dir(),is_link(),filectime(),fileatime(),filemtime(),fileinode(),filegroup(),fileowner(),filesize(),filetype() 和 fileperms()。 由于文件处理速度慢,为了更快处理,php保存了文件状态。比如说file_exists(),如果在一个页面,你先已判断了一个文件是否存在(假设存在),如果你在删除它,然后判断一次,他还会认为存在,除非你用clearstatcache();来清除状态缓存