Laravel 5.3:kcfinder图片上传无法正常工作

时间:2016-12-13 10:51:23

标签: php laravel ckeditor image-uploading kcfinder

我将这些代码放在ckeditor配置文件中。

// ...
config.filebrowserBrowseUrl = '/kcfinder/browse.php?opener=ckeditor&type=files';
config.filebrowserImageBrowseUrl = '/kcfinder/browse.php?opener=ckeditor&type=images';
config.filebrowserFlashBrowseUrl = '/kcfinder/browse.php?opener=ckeditor&type=flash';
config.filebrowserUploadUrl = '/kcfinder/upload.php?opener=ckeditor&type=files';
config.filebrowserImageUploadUrl = '/kcfinder/upload.php?opener=ckeditor&type=images';
config.filebrowserFlashUploadUrl = '/kcfinder/upload.php?opener=ckeditor&type=flash';
// ...

结果KCFinder按钮(链接,上传,浏览,发送到服务器)在textarea中正确显示。但是当我将图像发送到服务器时,它会显示

Object not found!

The requested URL was not found on this server. The link on the
referring page seems to be wrong or outdated. Please inform the 
author of that page about the error.

If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/7.0.1

在那段时间url显示

http://localhost/kcfinder/browse.php?opener=ckeditor&type=images&
CKEditor=post&CKEditorFuncNum=1&langCode=en

我在浏览器中打开了一个新的Tab,在网址中添加了我的网站名称(ewt)。它会正确打开页面,我可以从那里上传图像。

更改的网址是:(我在loacalhost和kcfinder之间添加了ewt)

http://localhost/ewt/kcfinder/browse.php?opener=ckeditor&type=images&
CKEditor=post&CKEditorFuncNum=1&langCode=en

如何在ckeditor配置文件的url中添加ewt? 我试过了

{{url()}}, base_url(), url() 

等。但不行。 我需要帮助......

3 个答案:

答案 0 :(得分:0)

我不确定,但我猜路径存在问题。

config.filebrowserBrowseUrl = '/kcfinder/browse.php?opener=ckeditor&type=files';
config.filebrowserImageBrowseUrl = '/kcfinder/browse.php?opener=ckeditor&type=images';
config.filebrowserFlashBrowseUrl = '/kcfinder/browse.php?opener=ckeditor&type=flash';
config.filebrowserUploadUrl = '/kcfinder/upload.php?opener=ckeditor&type=files';
config.filebrowserImageUploadUrl = '/kcfinder/upload.php?opener=ckeditor&type=images';
config.filebrowserFlashUploadUrl = '/kcfinder/upload.php?opener=ckeditor&type=flash';

从每条路径的开头删除/

config.filebrowserBrowseUrl = 'kcfinder/browse.php?opener=ckeditor&type=files';
config.filebrowserImageBrowseUrl = 'kcfinder/browse.php?opener=ckeditor&type=images';
config.filebrowserFlashBrowseUrl = 'kcfinder/browse.php?opener=ckeditor&type=flash';
config.filebrowserUploadUrl = 'kcfinder/upload.php?opener=ckeditor&type=files';
config.filebrowserImageUploadUrl = 'kcfinder/upload.php?opener=ckeditor&type=images';
config.filebrowserFlashUploadUrl = 'kcfinder/upload.php?opener=ckeditor&type=flash';

如果仍然不起作用,您可以在浏览器扩展程序的帮助下跟踪此路径问题,说Firebug来检查http请求。

一些有用的网络扩展程序

  1. Fiddler
  2. Firebug
  3. Tamper data
  4. 希望这对你有所帮助!

答案 1 :(得分:0)

根据您的信息,kcfinder位于您网站根目录下的ewt文件夹下。因此,请将配置更改为:

config.filebrowserBrowseUrl = '/ewt/kcfinder/browse.php?opener=ckeditor&type=files';
config.filebrowserImageBrowseUrl = '/ewt/kcfinder/browse.php?opener=ckeditor&type=images';
config.filebrowserFlashBrowseUrl = '/ewt/kcfinder/browse.php?opener=ckeditor&type=flash';
config.filebrowserUploadUrl = '/ewt/kcfinder/upload.php?opener=ckeditor&type=files';
config.filebrowserImageUploadUrl = '/ewt/kcfinder/upload.php?opener=ckeditor&type=images';
config.filebrowserFlashUploadUrl = '/ewt/kcfinder/upload.php?opener=ckeditor&type=flash';

答案 2 :(得分:0)

<强>解决 我添加了像这样的完整网址

// ...
config.filebrowserBrowseUrl = 'http://localhost/ewt/kcfinder/browse.php?opener=ckeditor&type=files';
config.filebrowserImageBrowseUrl = 'http://localhost/ewt/kcfinder/browse.php?opener=ckeditor&type=images';
config.filebrowserFlashBrowseUrl = 'http://localhost/ewt/kcfinder/browse.php?opener=ckeditor&type=flash';
config.filebrowserUploadUrl = 'http://localhost/ewt/kcfinder/upload.php?opener=ckeditor&type=files';
config.filebrowserImageUploadUrl = 'http://localhost/ewt/kcfinder/upload.php?opener=ckeditor&type=images';
config.filebrowserFlashUploadUrl = 'http://localhost/ewt/kcfinder/upload.php?opener=ckeditor&type=flash';
// ...

现在问题是已解决