发表文章时自动保存图片(zt)
2005-10-20 14:51
239 查看
$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);
$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实现发表文章时自动保存图片
- 发表文章时自动保存到剪贴板
- asp把文章内容中涉及到的图片自动保存到本地服务器
- 编辑文章时怎么让 远程保存图片自动打勾?
- php自动保存文章内容中的图片
- 发表文章时自动保存到剪贴板
- 把文章内容中涉及到的图片自动保存到本地服务器
- 如果你想推荐本文到CSDN 技术中心,请选择下列的文章分类之一。文章保存时将自动提交到CSDN技术中心,通过审核后本文将出现在您的CSDN 技术中心的专栏中。如果您不希望本文被提交到CSDN技术中心,请选择"不发表到CSDN技术中心"。注:还没有C
- 开源DIGG软件PBDigg2.0的修改(九):单独设置文章“是否保存远存图片”
- Discuz 3.X 门户文章插入图片自动添加 alt 标签
- JAVA实现自动打开URL对应的网页并保存为图片-不借助第三方API
- 实现app上对csdn的文章查看,以及文章中图片的保存 (制作csdn app 完结篇)
- WebView加载HTML图片大小自适应与文章自动换行
- echarts 生成统计图时,自动保存图片到服务器,并使用freemarker生成word
- dedecms5.7utf8 文章编辑 加上自动排版,简体繁体转换,图片排版
- php+ajax实现文章自动保存的方法
- C# 手动/自动保存图片
- Dede(织梦)发表文章时,内容自动添加关键字链接的方法-详解
- 动易首页调用最新文章图片向上滚动方法(ZT)
- 远程图片自动保存到本地服务器