时间:2016-02-16 19:10 来源: 我爱IT技术网 作者:佚名
欢迎您访问我爱IT技术网,今天小编为你分享的电脑教程之dedeCMS系列教程:【DEDE图片集上传图片时出错显示(FILEID)的解决方法】,请阅读以下详细内容!
DEDE图片集上传图片时出错显示(FILEID)的解决方法
<?php
//remove the utf-8 boms
//by magicbug at gmail dot com
if (isset($_GET['dir'])){ //config the basedir
$basedir=$_GET['dir'];
}else{
$basedir='.';
}
$auto=1;
checkdir($basedir);
function checkdir($basedir){
if ($dh=opendir($basedir)) {
while (($file=readdir($dh)) !==false) {
if ($file !='.' && $file !='..'){
if (!is_dir($basedir."/".$file)) {
echo "filename: $basedir/$file ";
echo checkBOM("$basedir/$file")."
";
}else{
$dirname=$basedir."/".$file;
checkdir($dirname);
}
}
}
closedir($dh);
}
}
function checkBOM ($filename) {
global $auto;
$contents=file_get_contents($filename);
$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);
return ("<font color=red>BOM found, automatically removed.</font>");
} 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);
}
?>保存为a.php,放在网站根目录访问下就可以了。
ps:如果在访问a.php的时候报错如:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted
那就试用下面的修改版检查出有bom的文件自己修改吧
<?php
//remove the utf-8 boms
//by magicbug at gmail dot com
if (isset($_GET['dir'])){ //config the basedir
$basedir=$_GET['dir'];
}else{
$basedir='.';
}
$auto=1;
checkdir($basedir);
echo ("
<font color=green>completed!</font>
");
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);
}
}
}
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>
");
} 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);
}
?>
关于DEDE图片集上传图片时出错显示(FILEID)的解决方法的用户互动如下:
相关问题:
答: >>详细
相关问题:
答: >>详细
相关问题:
答: >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
