stevenyangecho / laravel-u-editor

UEditor for laravel5. Support i18n. UEditor is a Rich Text Web Editor From Baidu.
MIT License
306 stars 82 forks source link

不能上传图片--总结 #21

Open jiangguoliang opened 8 years ago

jiangguoliang commented 8 years ago

首选非常感谢作者提供这个,谢谢!

我的laravel项目是5.1,我调试了差不多1天的时间,最终解决了这问题,希望能帮助其他同学;

1、第一次先不用开启auth认证 //'middleware' => 'auth', 注释掉这一行 2、blade试图文件中一定要设置如下: var ue1 = UE.getEditor('UeContent1'); ue1.ready(function () { ue1.execCommand('serverparam', '_token', '{{ csrf_token() }}'); }); 3、自己使用chrome浏览器F12看一看具体信息,一切便知晓,问题也就迎刃而解了

jiangguoliang commented 8 years ago

补充一点:

如果你的blade试图中有多个编辑器,请注意设置变量,如下: index.blade.php中有2个编辑器

var ue1 = UE.getEditor('UeContent1'); ue1.ready(function () { ue1.execCommand('serverparam', '_token', '{{ csrf_token() }}'); }); var ue2 = UE.getEditor('UeContent2'); ue2.ready(function () { ue2.execCommand('serverparam', '_token', '{{ csrf_token() }}'); });

SwingWillwow commented 7 years ago

@jiangguoliang 你好,我最近刚开始学laravel框架,按你说的做了还是没懂怎么上传图片,能不能详细点告诉我,谢谢啦。

jiangguoliang commented 7 years ago

你的错误信息提示是什么?

SwingWillwow commented 7 years ago

我这边从开发者工具看到一个404的错误,说找不到 laravel-u-editor/server,我加了一条路由还是不行。

jiangguoliang commented 7 years ago

找到目录:laravel项目的根目录 /public/laravel-u-editor文件夹下的ueditor.config.js文件 找到大约第33行左右,看看代码是否如下: // 服务器统一请求接口路径 , serverUrl: "/laravel-u-editor-server/server"

jiangguoliang commented 7 years ago

你最好是Chrome浏览器F12看一下具体信息

SwingWillwow commented 7 years ago

好的,我晚上回来试试,下午有课。谢谢你了真热心,刚问就回复我了。

jiangguoliang commented 7 years ago

客气了,大家共同学习~!

shanghenggit commented 7 years ago

图片上传提示,后台配置没有正常加载。f12提示找不到/laravel-uditor-server/server。配置文件是正常的。我的laravel版本是5.4

shanghenggit commented 7 years ago

请求的地址:http://192.168.10.2/laravel-u-editor-server/server?action=config&&noCache=1498148207831

hongyukeji commented 7 years ago

找到文件:/vendor/stevenyangecho/laravel-u-editor/src/Uploader/Upload.php 131行:$randNum = rand(1, 10000000000) . rand(1, 10000000000); 修改为:$randNum = rand(1, 100000) . rand(1, 100000);

BoykaDan commented 7 years ago

注释掉的那个在真正上线的时候肯定还是要进行auth认证的呀,到时候咋整呀

kerneltravel commented 6 years ago

下面debug信息就是 @hongyukeji 说的修改的原因。否则上传的请求会得到显示http错误500。

根源信息: (1/1) ErrorException rand() expects parameter 2 to be integer, float given

in Upload.php line 131 at HandleExceptions->handleError(2, 'rand() expects parameter 2 to be integer, float given', 'C:\……\laravel-store\vendor\stevenyangecho\laravel-u-editor\src\Uploader\Upload.php', 131, array('t' => 1536206008, 'd' => array('2018', '18', '09', '06', '03', '53', '28'), 'format' => '/upload/image/20180906/1536206008{rand:6}', 'oriName' => '140x100')) at rand(1, 10000000000.0) in Upload.php line 131 at Upload->getFullName() in UploadFile.php line 38 at UploadFile->doUpload() in Upload.php line 73 at Upload->upload() in Controller.php line 39 at Controller->server(object(Request)) at call_user_func_array(array(object(Controller), 'server'), array(object(Request))) in Controller.php line 54 at Controller->callAction('server', array(object(Request))) in ControllerDispatcher.php line 45 at ControllerDispatcher->dispatch(object(Route), object(Controller), 'server') in Route.php line 204 at Route->runController() in Route.php line 161 at Route->run() in Router.php line 610 at Router->Illuminate\Routing{closure}(object(Request)) in Pipeline.php line 30 at Pipeline->Illuminate\Routing{closure}(object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in Router.php line 612 at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 571 at Router->dispatchToRoute(object(Request)) in Router.php line 549 at Router->dispatch(object(Request)) in Kernel.php line 176 at Kernel->Illuminate\Foundation\Http{closure}(object(Request)) in Pipeline.php line 30 at Pipeline->Illuminate\Routing{closure}(object(Request)) in InjectDebugbar.php line 65 at InjectDebugbar->handle(object(Request), object(Closure)) in Pipeline.php line 149 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 53 at Pipeline->Illuminate\Routing{closure}(object(Request)) in CheckForMaintenanceMode.php line 46 at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 149 at Pipeline->Illuminate\Pipeline{closure}(object(Request)) in Pipeline.php line 53 at Pipeline->Illuminate\Routing{closure}(object(Request)) in Pipeline.php line 102 at Pipeline->then(object(Closure)) in Kernel.php line 151 at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116 at Kernel->handle(object(Request)) in index.php line 53

_20180906121403
milk-coffee-tea commented 5 years ago

我的页面中没有报错,laravel-u-editor-server/server?action=config&&noCache=1545359233795也请求成功,但是页面还是显示后端配置项没有正常加载,上传插件不能正常使用,请问知道是为什么吗