> php教程 > php手册 > 본문

keditor_php 이미지 업로드

WBOY
풀어 주다: 2016-08-30 09:21:14
원래의
1397명이 탐색했습니다.

 
 
 
 
 
 

html:


                            
                          

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

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

                             
                        

                        

//백엔드 코드

//Keditor 편집기 업로드 이미지 처리
공개 함수 ke_upimg(){
/* 표준 데이터 반환*/
$return = array('error' => 0, 'info' = > ; '업로드 성공', 'data' => '');
$img = $this->upload();
/* 첨부 파일 정보 기록*/
if($img) {
                                                                                                                                          > $return['error'] = 1;
$return['message'] = session('upload_error');
}

/* JSON 데이터 반환*/
종료 (json_encode($return));
}


/* 이미지 업로드*/
공개 함수 upload(){
session('upload_error', null) ;
                                                        / 'maxSize' =>3145728,
('jpg', 'gif', 'png', 'jpeg'),
        'autoSub' => true,
            'subName ' => array('date','Ymd'),
);
$this->uploader = new ThinkUpload($config, 'Local');
$info = $this- >uploader->upload($_FILES);
/ /Log::write(print_r($info));
If($info){
$url = '/Uploads'.$ info['imgFile']['savepath'].$info[' imgFile']['savename'];
$url = str_replace('./', '/', $url);
$ info['fullpath'] = __ROOT__.$url;
}

session('upload_error', $this->uploader->getError());

return $ info;
}

/**
* 사진 업로드
*/
공개 함수 uploadPicture(){
//TODO: 사용자 로그인 감지
/* 표준 데이터 반환*/
$return = array('status' => 1, ' info' => '업로드 성공', 'data' => ''); './news/',
'saveName' => array('uniqid',''),
'exts' => array('jpg', 'gif', 'png', 'jpeg'),
'AutoSub' = & GT;
'하위 이름' = & GT; 배열('날짜', 'YMD'),
$ this- & gt; 로컬');
$info = $this->uploader->upload($_FILES);

                                                                                                             ~                                     ​['savename'];
$url = str_replace('./', '/', $url);
$return['path'] = __ROOT__.$url;
$return[' id'] = 111;
             $return['status'] = 1;
               $return['info']                      | ($return);
}



js 스크립트, 첫 번째 이미지 추출:

//첫 번째 사진 가져오기
$('#autolitpic').click(function (){
if($(this).attr('checked')){
$( this ).attr('checked',false);

}else {

$(this).attr('checked',true);

var content=$('.content').val ( );

if(content.match(/src="[^"]+"/g)==null){

Alert('기사 내용에 사진이 없습니다');

return ;
Else {
Var Strcount = Content.match (/SRC = "[^"]/G) [0] .RePlace ("src =" "," ");
var valcount .substring (0,strcount.length-1).replace("http://cb2013.tdedu.org","");
                       $("#thumb_img").attr('src',val)
                                                                                                          > } );





관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 추천
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!