asp.net-mvc CKEditor 图片上传

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1461261/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-07 23:52:08  来源:igfitidea点击:

CKEditor Image Upload

asp.net-mvcckeditorwysiwygimage-uploading

提问by Nathan Taylor

I am looking to include CKEditorin a project I am working on and I need the image upload support provided by the CKFinderplugin, however I do not particularly need the rest of the CKFinder tool and thus purchasing a license is a little overkill. Has anyone taken the time to implement a custom image uploader for CKEditor 3 that will work with ASP.NET MVC? If need be I can create my own, just wanted to check here first.

我希望将CKEditor包含在我正在处理的项目中,我需要CKFinder插件提供的图像上传支持,但是我并不特别需要 CKFinder 工具的其余部分,因此购买许可证有点过头了。有没有人花时间为 CKEditor 3 实现一个可以与 ASP.NET MVC 一起使用的自定义图像上传器?如果需要,我可以创建自己的,只是想先在这里检查一下。

Alternatively, does anyone know of a decent WYSIWYG editor on par with CKEditor/ Cute Editorthat supports image uploading and will work in ASP.NET MVC?

或者,有没有人知道一个像CKEditor/ Cute Editor 一样体面的 WYSIWYG 编辑,它支持图像上传并且可以在 ASP.NET MVC 中工作?

回答by Michael

Here is a image uploader I originally wrote in ASP.NET WebForms for Fckeditor (hence the theme no longer matches), that I've modified to work with Ckeditor.

这是我最初在 ASP.NET WebForms 中为 Fckeditor 编写的图像上传器(因此主题不再匹配),我已对其进行修改以与 Ckeditor 一起使用。

https://github.com/mcm-ham/ckeditor-image-uploader

https://github.com/mcm-ham/ckeditor-image-uploader

Update: I've now added an example showing how you can add this WebForms image uploader to a MVC project.

更新:我现在添加了一个示例,展示如何将这个 WebForms 图像上传器添加到 MVC 项目。

Update 2: I've now added a Razor Pages version which can be used in .NET Core MVC projects.

更新 2:我现在添加了一个可以在 .NET Core MVC 项目中使用的 Razor Pages 版本。

回答by Artur K?dzior

Here is a tutorial on how to upload image with ASP:NET MVC2 (not Webforms) using CKEditor

这是一个关于如何使用 CKEditor 使用 ASP:NET MVC2(不是 Webforms)上传图像的教程

http://arturito.net/2010/11/03/file-and-image-upload-with-asp-net-mvc2-with-ckeditor-wysiwyg-rich-text-editor/

http://arturito.net/2010/11/03/file-and-image-upload-with-asp-net-mvc2-with-ckeditor-wysiwyg-rich-text-editor/

回答by David Avsajanishvili

If you need to implement it quickly and have a reliable solution, you may consider a hosted solution to upload and store images for CKEditor - for example, our plugin:

如果您需要快速实施并拥有可靠的解决方案,您可以考虑使用托管解决方案为 CKEditor 上传和存储图像 - 例如,我们的插件:

http://ckeditor.com/addon/uploadcare

http://ckeditor.com/addon/uploadcare

回答by David Avsajanishvili

I have used ckeditor and the upload control using ASP.NET, but not MVC specifically. I haven't found anything on par with ckeditor that is even close to being as easy to set up or offers the same features.

我使用了 ckeditor 和使用 ASP.NET 的上传控件,但没有专门使用 MVC。我还没有发现任何与 ckeditor 相提并论的东西,它甚至接近于易于设置或提供相同的功能。

Not sure of the restrictions for MVC, but I set up file upload support by using the following:

不确定 MVC 的限制,但我使用以下方法设置文件上传支持:

  • The basic documentation referring mostly to the CKFinder plugin you mentioned:
  • 基本文档主要是指您提到的 CKFinder 插件:

http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_%28Uploader%29

http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_%28Uploader%29

  • Better documentation on how to implement the upload component:
  • 关于如何实现上传组件的更好的文档:

How can you integrate a custom file browser/uploader with CKEditor?

如何将自定义文件浏览器/上传器与 CKEditor 集成?

Otherwise, I believe ckeditor just stuffs all the image bytes in the request object and sends it to the page configured for uploading. This page can take those bytes and do whatever it pleases (i.e. save them to the file system, sql server, etc.) This is where the custom implementation comes in.

否则,我相信 ckeditor 只是填充请求对象中的所有图像字节并将其发送到配置为上传的页面。这个页面可以使用这些字节并做任何想做的事情(即,将它们保存到文件系统、sql server 等)。这就是自定义实现的用武之地。

Instead of using a page to do the upload, I used an httphandler implementation. The page ckeditor redirects to calls the requisite javascript function to indicate the status of the upload after it is complete, but the handler really controls the actual file upload. The basic implementation for the httphandler I used is at:

我没有使用页面进行上传,而是使用了 httphandler 实现。页面 ckeditor 重定向到调用必需的 javascript 函数来指示上传完成后的状态,但处理程序真正控制实际的文件上传。我使用的 httphandler 的基本实现位于:

http://darrenjohnstone.net/2008/07/15/aspnet-file-upload-module-version-2-beta-1/

http://darrenjohnstone.net/2008/07/15/aspnet-file-upload-module-version-2-beta-1/

Hope this at least gives you a starting point.

希望这至少可以为您提供一个起点。



UPDATE: found this while searching for some other stuff. Didn't look at in depth, but seems to be right up your alley:

更新:在搜索其他一些东西时发现了这个。没有深入研究,但似乎就在你的小巷里:

http://interactiveasp.net/blogs/spgilmore/archive/2009/06/03/how-to-support-file-uploads-in-asp-net-mvc.aspx

http://interactiveasp.net/blogs/spgilmore/archive/2009/06/03/how-to-support-file-uploads-in-asp-net-mvc.aspx