PHP实现发表文章时自动保存图片

简介:这是PHP实现发表文章时自动保存图片的详细页面,介绍了和php,有关的知识、技巧、经验,和一些php源码等。

class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=323997' scrolling='no'> $img_array = array();
$content1 = stripslashes($content1);
if (get_magic_quotes_gpc()) $content1 = stripslashes($content1);
//echo $content1;
preg_match_all("/(src│SRC)="(http://(. ).(gif│jpg│jpeg│bmp│png))/isU",$content1,$img_array);
$img_array = array_unique(dhtmlspecialchars($img_array[2]));
set_time_limit(0);
foreach ($img_array as $key => $value) {
$get_file = file_get_contents($value);
$filetime = time();
$filepath = "../uploadfile/".date("Y",$filetime)."/".date("m",$filetime)."/";
!is_dir($filepath) ? mkdirs($filepath) : null;
$filename = date("YmdHis",$filetime).random(1).'.'.substr($value,-3,3);
$fp = @fopen($filepath.$filename,"w");
@fwrite($fp,$get_file);
fclose($fp);
$content1 = preg_replace("/".addcslashes($value,"/")."/isU", "/uploadfile/".date("Y",$filetime)."/".date("m",$filetime)."/".$filename, $content1);

“PHP实现发表文章时自动保存图片”的更多相关文章 》

爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具

http://biancheng.dnbcw.info/php/323997.html pageNo:15

posted on 2011-11-19 11:36  圣者  阅读(228)  评论(0编辑  收藏  举报

导航