首頁 > php教程 > php手册 > 主體

keditor_php圖片上傳

WBOY
發布: 2016-08-30 09:21:14
原創
1397 人瀏覽過

 
 
 
 
 
 

html:


                            
                          

                                (分页符为:
                                #p#分页-标题#e#)
                                
                                
                                (
                                [取消缩略图]
                                )
                                

                            *
                            
必填项,可无限输入,没有字数限制.

                     
                                
                                                KindEditor.ready(function(K) {             編輯器_content1 = K.create ('textarea[name="content"]', {
                                           allowFileManager : false ,
                                            主題路徑: K. basePath,
                                            寬度: '900px',
                                           高度: '700px',
                                           調整大小類型:1,
                                                                         cssPath : '/statics/js/kin                            uploadJson : '{:U('ke_upimg')}',                 afterCreate : function() {
                                                                                           afterBlur:function(){
                  這個.sync();
                                               }   
                                        });
                                        prettyPrint();
                                    });    
                                    
                            
                        

                        
  

//後台代碼

//keditor編輯器上傳圖片處理
    public function ke_upimg(){
        /* 返回標準資料*/
   => '');
        $img = $this->upload();
        /* 記錄附件資訊*/
    img['fullpath'];
            unset($return['info'], $return['data']);
        } else {        $return['message']  = session('upload_error') ;
        }
    
        /* 回傳JSON資料*/
        
        /* 上傳圖片*/
    public function upload(){
        session('upload_error', null);
        /* 上傳設定*/
        $setting = C('EDITOR_UPLOAD');
         $config = array(
            'maxSize' => 3145728,
       './news/',
            'saveName' => array('uniqid',''),
               ' autoSub' => true,
            'subName' => array('date','Ymd'),
        );
          $info = $this ->uploader->upload($_FILES);
        //Log::write(print_r($info));
        if($info 'savepath'].$info['imgFile']['savename'];
            $url = str_replace('./', '/', $url); ;
        }
        
        session('upload_error', $this-p info;
    }
    
    /**
     * 上傳圖片
    */
    public function uploadPicture(){
     public function uploadPicture(){
  /TODO: 使用者登入偵測
        /* 傳回標準資料*/
        $return  = array('status' => 1, 'info' => '上傳成功', 'data' = ''    $config = array(
                'maxSize' => 3145728,
                'saveName' => array('uniqid',''),
                'exts' => array('jpg ', 'gif', 'png', 'jpeg'),
                'autoSub' => true,
           );
        $this->uploader = new ThinkUpload($config, 'Local');
        $info = $this->uploader->upload($_FILES);

        /* 記錄圖片資訊*/
        if($info){
           發現$$
            $url = str_replace('./', '/', $url);
          'id'] = 111;
            $return['status '] = 1;
            $return = array_merge($info['download'], $return);
                   $return['info']   = $this- >uploader->getError();
        }

       /* 回傳JSON資料*/
    
 

js腳本,擷取第一張圖片:

//取得第一張圖片

$('#autolitpic').click(function (){

    if($(this).attr('checked')){

   ,false);

    }else {

        $(this).attr('checked',true);
        [^"]+"/g)==null){
            alert('文章內容無圖片');
                var strcount=content.match(/src="[^"]+" /g)[0].replace("src="","");
               var val=strcount.substring(0,strcount.length-1).replace("http://cb2013.tdedu.org" "");
               $("#thumb_img").attr('src',val);
        }
        }
    });

//取消縮短略圖
$('.qximg').click(function (){
    $("#thumb_img").attr('src',"");
    $("#img").val("");
});





相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!