html:
//Backend-Code
//Keditor-Editor Bildverarbeitung hochladen
öffentliche Funktion ke_upimg(){
/* Standarddaten zurückgeben*/
$return = array('error' => 0, 'info' = > ; 'Hochladen erfolgreich', 'data' => '');
$img = $this->upload();
/* Anhangsinformationen aufzeichnen*/
if($img) {
> $return['error'] = 1;
$return['message'] = session('upload_error');
}
/* JSON-Daten zurückgeben*/
exit (json_encode($return));
}
/* Bild hochladen*/
public function 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;
}
/**
* Bilder hochladen
*/
öffentliche Funktion uploadPicture(){
//TODO: Benutzer-Login-Erkennung
/* Standarddaten zurückgeben*/
$return = array('status' => 1, ' info' => 'Upload erfolgreich', 'data' => ''); ath' => ; > 'saveName' => array('uniqid',''),
'exts' => array('jpg', 'gif', 'png', 'jpeg'),
'AutoSub ' = & GT;
'Subname' = & GT; Array ('Datum', 'YMD'),
$ this- & gt; 'Lokal');
$info = $this->uploader->upload($_FILES);
$return['id'] = 111;
$return['status'] = 1; ['status'] = 0;
$return['info'] 🎜> $this->ajaxReturn ($return);
}
js-Skript, extrahieren Sie das erste Bild:
//Das erste Bild abrufen
$('#autolitpic').click(function (){
if($(this).attr('checked')){
$( this ).attr('checked',false);
}else {
$(this).attr('checked',true);
var content=$('.content').val ( );
Alert('Der Artikelinhalt enthält keine Bilder');
return;}else{
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) ;
click(function (){
$("#thumb_img").attr('src',"");
$("#img").val("");
});