1、下载UMeditor
地址:http://ueditor.baidu.com/website/umeditor.html
2、在UMeditor的目录下有个php文件夹,找到
Uploader.class.php
修改如下:
<span style="font-size:14px;"> private function upFile( $base64 )
{
//处理base64上传
if ( "base64" == $base64 ) {
$content = $_POST[ $this->fileField ];
$this->base64ToImage( $content );
return;
}
//处理普通上传
$file = $this->file = $_FILES[ $this->fileField ];
if ( !$file ) {
$this->stateInfo = $this->getStateInfo( 'POST' );
return;
}
if ( $this->file[ 'error' ] ) {
$this->stateInfo = $this->getStateInfo( $file[ 'error' ] );
return;
}
if ( !is_uploaded_file( $file[ 'tmp_name' ] ) ) {
$this->stateInfo = $this->getStateInfo( "UNKNOWN" );
return;
}
$this->oriName = $file[ 'name' ];
$this->fileSize = $file[ 'size' ];
$this->fileType = $this->getFileExt();
if ( !$this->checkSize() ) {
$this->stateInfo = $this->getStateInfo( "SIZE" );
return;
}
if ( !$this->checkType() ) {
$this->stateInfo = $this->getStateInfo( "TYPE" );
return;
}
$folder = '';
//$folder = $this->getFolder();
//if ( $folder === false ) {
// $this->stateInfo = $this->getStateInfo( "DIR_ERROR" );
// return;
//}
$fname = $this->getName() ;
$this->fullName = 'http://您应用名称-upload.stor.sinaapp.com/'.$fname;
if ( $this->stateInfo == $this->stateMap[ 0 ] ) {
//if ( !move_uploaded_file( $file[ "tmp_name" ] , $this->fullName ) ) {
if ($this->uploadFile($fname,$file)==='1') {
$this->stateInfo = $this->getStateInfo( "MOVE" );
}
}
}
private function uploadFile($fileName,$file){
$stor = new SaeStorage();
$domain = 'upload';//我刚创建的domain的名称
$url = NULL;
$fileDataName = $fileName;
$dumpdata = file_get_contents($file["tmp_name"]);
$dowLoadUrl = $stor->write($domain,$fileDataName,$dumpdata);//用write就行了
$url = $stor->getUrl($domain,$fileDataName);//如果上传图片的处理地址
if (!$url){
return "1";
}
else{
return "0" ;
}
}<span style="white-space:pre"> </span></span>
说明:主要是增加uploadFile 方法替换原来的文件保存方式,注释原来的新建文件夹方法
3、修改umeditor.config.js
,imagePath:"" //图片修正地址,引用了fixedImagePath,如有特殊需求,可自行配置
这里修改如上,让编辑器取图片绝对路径