直接贴代码:
/app/publish/ajax.php 文件内增加
搜索 $this->publish_approval_valid() 在这个上面新增以下代码就可以了
if($_POST['question_detail']){
            
            $pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png]))[\'|\"].*?[\/]?>/";
            preg_match_all($pattern,$_POST['question_detail'],$match);
            if($match[1]){
                foreach($match[1] as $key => $val){
                    $img = file_get_contents($val);
                    if($img){
                        $dir = 'uploads/questions/'.date('Ymd').'';
                        if (!file_exists(ROOT_PATH.$dir)){
                            mkdir(ROOT_PATH.$dir,0777);
                        }
                        $url = $dir.'/'.time().rand(0,999).'.jpg';
                        file_put_contents(ROOT_PATH.$url,$img);
                        $_POST['question_detail'] = str_replace($val, $url, $_POST['question_detail']);
                    }
                }
            }
        }
这样 就不用担心图片打不开等问题.所有图片保存至服务器..
编辑人员的工作就会减少许多,不用在一张张下载下来 然后在上传了...
温馨提示:所有编辑器内的外部图片都会保存至本地. 所以尽量图片不要多
太多 提交会太慢.
这是最后一篇分享 已经换公司了.
感谢.wecenter
                                                                
                                     阅读全文
                                
                                
                                     收起全文