All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

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

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/2/10 6:48:42 Browse times: 336 Comment times: 0

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


Head photo

Go homepage
Upload pictures
Write articles

PHP实现发表文章时自动保存图片_[PHP教程] 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);




There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.