
解决方案:
方法一:
首先检查upload目录权限
然后检查下是否为utf-8无bom格式。
可通过以下文件放到根目录检查,直接保存为a.php然后预览就可以了
- <?php
- //remove the utf-8 boms
- if (isset($_GET['dir'])){ //config the basedir
- $basedir=$_GET['dir'];
- }else{
- $basedir = '.';
- }
- $auto = 1;
- checkdir($basedir);
- echo ("<br><br><font color=green>completed!</font><br>");
- function checkdir($basedir)
- {
- if ($dh = opendir($basedir))
- {
- while (($file = readdir($dh)) !== false)
- {
- if ($file != '.' && $file != '..')
- {
- if (!is_dir($basedir."/".$file))
- {
- //echo "filename: $basedir/$file ";
- checkBOM("$basedir/$file");
- }
- else
- {
- $dirname = $basedir."/".$file;
- checkdir($dirname);//ruoshuiyx.com
- }
- }
- }
- closedir($dh);
- }
- }
- function checkBOM ($filename) {
- global $auto;
- $contents = file_get_contents($filename,NULL,NULL,0,10);
- $charset[1] = substr($contents, 0, 1);
- $charset[2] = substr($contents, 1, 1);
- $charset[3] = substr($contents, 2, 1);
- if (ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191) {
- if ($auto == 1) {
- //$rest = substr($contents, 3);
- //rewrite ($filename, $rest);
- echo ($filename."--------"."<font color=red>BOM found</font><br>");
- } else {
- //return ("<font color=red>BOM found.</font>");
- }
- }
- //else return ("BOM Not Found.");
- }
- function rewrite ($filename, $data) {
- $filenum = fopen($filename, "w");
- flock($filenum, LOCK_EX);
- fwrite($filenum, $data);
- fclose($filenum);
- }
- ?>
方法二:
大致都是说只有UTF-8编码的才会有问题。
试了第一个发现不能用,按照那个方法处理完还是会出现那个问题。再打开下面的哪些链接,发现居然都是转载的同一个文章,作者瞬间凌乱了。这种不能解决问题的方法为何大家争相转载呢?作者继续找,终于找到了。
具体方法如下:
在/dede/swfupload.php的
echo "FILEID:".$_SESSION['fileid'];
的上边加一句
ob_end_clean();
这回能上传了,但上传后图片依然输不出来,于是在chrome的指引下,还多出几个回车,于是这的上边加一句,在
header('Content-type: image/jpeg');
header('Content-Length: '.strlen($_SESSION['file_info'][$id]));
的上边加一句
ob_end_clean();
这回终于可以输出了!看来ob_end_clean(); 函数的作用很大啊!
效果图如下: