PHP code example of zhangmazi / laravel-ueditor
1. Go to this page and download the library: Download zhangmazi/laravel-ueditor library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zhangmazi / laravel-ueditor example snippets
Zhangmazi\Ueditor\UeditorServiceProivder::class
/**
* 自定义的编辑器控制器.
* 可以观看 Zhangmazi\Ueditor\UeditorUploaderAbstract 复用类的方法,根据自身业务选择性重写覆盖
*
* @author ninja911<[email protected] >
* @date 2016-08-20 22:22
*/
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Zhangmazi\Ueditor\UeditorUploaderAbstract;
class CustomUeditorController extends Controller
{
use UeditorUploaderAbstract;
/**
* 记录上传日志(这些方法都可以重写覆盖)
* @return mixed
*/
protected function insertRecord()
{
}
/**
* 验证是否合法(这些方法都可以重写覆盖)
* @return bool|mixed
*/
protected function checkGuard()
{
//如果是后端
//return Auth::check();
return true;
}
/**
* 获取相对于public_path()根目录的相对目录
* @return bool|mixed
*/
protected function getRelativeDir()
{
return 'uploads/ueditor';
}
/**
* 获取保存根目录路径
* @paraam string $driver_name 驱动名
* @return string
*/
protected function getSaveRootPath($driver_name = 'local')
{
return storage_path('app/ueditor');
}
/**
* 删除原始文件
* @param $file
* @return bool
*/
protected function deleteOriginFile($file)
{
File::delete($file['file_native_path']);
File::delete($file['origin_pic_native_path']);
return true;
}
}
shell
php artisan vendor:publish --provider="Zhangmazi\Ueditor\UeditorServiceProivder"
shell
php artisan serve --host=0.0.0.0 --port=8030
shell
php artisan route:list