首頁 >後端開發 >php教程 >PHP实现发表文章时自动保存图片_PHP教程

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

WBOY
WBOY原創
2016-07-13 10:59:08764瀏覽


$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);

?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/631969.htmlTechArticle?php $img_array = array(); $content1 = stripslashes($content1); if (get_magic_quotes_gpc()) $content1 = stripslashes($content1); //echo $content1; preg_match_all(/(src│SRC)=(http...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn