• 技术文章 >后端开发 >php教程

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

    2016-06-01 12:30:32原创425
    $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)."//m.sbmmt.com/m/".date("m",$filetime)."//m.sbmmt.com/m/";
    !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("//m.sbmmt.com/m/".addcslashes($value,"//m.sbmmt.com/m/")."/isU", "/uploadfile/".date("Y",$filetime)."//m.sbmmt.com/m/".date("m",$filetime)."//m.sbmmt.com/m/".$filename, $content1);
    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    上一篇:有关在Windows下配置PHP Apache Optimizer失败的问题解决方案_PHP 下一篇:PHP 5.0对象模型深度探索之属性和方法_PHP
    千万级数据并发解决方案

    相关文章推荐

    • php制作的简单验证码识别代码_php实例• PHP 读取和编写 XML_php实例• Destoon实现多表查询示例_php实例• CI使用Tank Auth转移数据库导致密码用户错误的解决办法_php实例• [PHP]实用函数3_php实例
    1/1

    PHP中文网