ASP. NET MVC4 implements TinyMCE 4.0.20 custom upload function

Source: Internet
Author: User

The tinymce plug-in does not provide a free local image upload function. Therefore, you can integrate the uploadify plug-in into tinymce to implement local upload. You also use the jquery. ui plug-in to first display all the code.

<Script type => = convert_fonts_to_spans: rule: force_br_newlines: force_p_newlines: remove_linebreaks: relative_urls: resize :::::: function (img = + data + ). dialog (). dialog (</script> <div> <form method = action => <textarea id = name = style => </textarea> <input type = value =/> </form> </div> <div id = style => <input type = name = id =/> <label> only images in png, jpg, and gif formats smaller than 10 MB can be uploaded. </label> </div>View Code

Next we will analyze it in several steps

1. Add the Custom button on the tinymce plug-in first

View Code

2. initialize the uploadify plug-in.

::::::: Function (img = + data +). dialog (). dialog (View Code

3. Click the Custom button and enable the jquery-ui dialog plug-in to bring up the upload dialog box.

=View Code

Now the front-end is partially OK, followed by the back-end

1. The background receives images uploaded by users.

Result = folder = Server. mapPath (time = DateTime. now. toString (); extension = System. IO. path. getExtension (Filedata. fileName); newFileName = time + extension ;(! ++View Code

2. Receive the content of the tinymce plug-in (I will simply use NotePad to replace the database), and then read the content from notepad and present it to another page.

Path = Server. MapPath (str = RedirectToAction (str = System. IO. File. ReadAllText (Server. MapPath (=View Code

In mvc4, html-tagged content is not allowed to be uploaded to the background by default to prevent script attacks. Therefore, I created TinyMCEModels and added the AllowHtml tag to the content attribute (in System. web. in the Mvc namespace ).

Content {;View Code

 

Source http://files.cnblogs.com/guzhehang/TinyMCEUpload.rar

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.