Saving nicedit textarea content into mysql database

此生再无相见时 提交于 2019-12-12 12:35:30

问题


I'm sort of a newbie so I would appreciate a very clear explanation, thanks in advance.

I'm using the nicedit textarea on a website, the information to be read could contain:

  • Just plain text (user formatted)

  • text and images together

I'm using a mysql database and I don't know how to save the content of the textarea in a way that:

  • the text can be read from the database without loosing the users formatting
  • the images in the textarea can be stored into the filesystem and reloaded when the text is being read back from the database (and putting the images in the position the user intended).

I'm using php if that's needed information.

I hope someone understands what I'm trying to get, any help is appreciated even if it's suggesting another approach ...


回答1:


You do not need to worry about saving the content because NicEdit saves all text & styles in HTML format. That HTML can easily be saved into a Text field in your database. The problem is that NicEdit does not sync the styling into the original text area, So when you submit the form the content is saved without the styling.

To solve this, you need to explicitly ask NicEdit to save the styling before you submit the form by adding this line:

nicEditors.findEditor('<you_textarea_id>').saveContent();


来源:https://stackoverflow.com/questions/30582700/saving-nicedit-textarea-content-into-mysql-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!