Mysql 使用TinyMCE发布的图像有大小限制吗?

Mysql 使用TinyMCE发布的图像有大小限制吗?,mysql,image,upload,tinymce,filesize,Mysql,Image,Upload,Tinymce,Filesize,我在一个网站上工作,其中包括一个博客类型的部分。我有一个发布系统,其中来自编辑器的输入被发送到mysql数据库表。到目前为止,除了添加本地图像外,其他一切都正常工作。如果图像的文件大小非常小,则图像可以工作,否则它不会显示,有时会清除$\u POST['body']中的所有内容。有没有一种方法可以放大图像 以下是php: <?php if(isset($_POST['title'], $_POST['body'])) { include 'php/m

我在一个网站上工作,其中包括一个博客类型的部分。我有一个发布系统,其中来自编辑器的输入被发送到mysql数据库表。到目前为止,除了添加本地图像外,其他一切都正常工作。如果图像的文件大小非常小,则图像可以工作,否则它不会显示,有时会清除$\u POST['body']中的所有内容。有没有一种方法可以放大图像

以下是php:

    <?php
        if(isset($_POST['title'], $_POST['body'])) {
        include 'php/mysql.php';
        date_default_timezone_set('America/New_York');
        $title = filter_input(INPUT_POST, 'title', FILTER_SANITIZE_STRING);
        $body = $_POST['body'];
        $date = date('Y/m/d');
        $query = "INSERT INTO posts(title,body,date) 
                VALUES('$title','$body','$date')";
        $insert = runQuery($query,$conn);
        if(!$insert) die($conn->error);
        redirect('News.php');

}

?>

<form id="get-data-form" method="post">
    <table>
        <tr>
            <td><label for="title">Title</label></td>
            <td><input name="title" id="title" /></td>
        </tr>
        <tr>
            <td valign="top"><label for="body">Body</label></td>
            <td><textarea name="body" class="tinymce" id="body">
            </textarea></td>
        </tr>
        <tr>
            <td></td>
            <td><input type="submit" value="Post" /></td>
        </tr>
    </table>
</form>

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="plugin/tinymce/tinymce.min.js"></script>
<script type="text/javascript" src="plugin/tinymce/init-tinymce.js"></script>

TinyMCE已经有了一种方法来处理插入本地映像并将其发送到服务器:


如果在初始化编辑器时在编辑器上配置此选项,则图像将自动神奇地上载,以便在插入时进行处理。这将实现您的最终目标,即图像位于服务器上,src属性仅指向图像,而不是在HTML内容中包含大的Base64图像。

我面临同样的问题,通过将列类型从文本更改为长文本来解决,而不是将图像保存在数据库中,最好将它们保存为文件夹中的文件。 根据tinymce文档,有两种方法可用于在服务器中上载图像

在表单提交之前使用上载图像 函数uploadImages将通过post方法将上传到编辑器的所有图像逐个发送到images\u upload\u url,并将该图像的scr属性设置为包含location属性的JSON对象

    tinymce.activeEditor.uploadImages(function(success) {
        document.forms[0].submit();
    });
服务器应该返回类似JSON的消息

{ location : '/uploaded/image/path/image.png' }
设置为发布图像的src属性

如果您要使用自定义逻辑的自己的方法,则使用它。 upload handler函数接受三个参数:blobInfo、成功回调和失败回调。它在编辑器中上载图像时触发,并通过XMLHttpRequest发送图像,并使用远程图像的位置调用成功回调

tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  images_upload_handler: function (blobInfo, success, failure) {
    var xhr, formData;

xhr = new XMLHttpRequest();
xhr.withCredentials = false;
xhr.open('POST', 'postAcceptor.php');

xhr.onload = function() {
  var json;

  if (xhr.status != 200) {
    failure('HTTP Error: ' + xhr.status);
    return;
  }

  json = JSON.parse(xhr.responseText);

  if (!json || typeof json.location != 'string') {
    failure('Invalid JSON: ' + xhr.responseText);
    return;
  }

  success(json.location);
};

formData = new FormData();
formData.append('file', blobInfo.blob(), blobInfo.filename());

xhr.send(formData);
  }});

如果有人知道一种方法,我可以修改上面的代码,将图像上传到“../images/”目录,然后让编辑器简单地在帖子中引用该位置,这可能会更好,而不是在mysql数据中嵌入实际图像。它适用于什么尺寸,不适用于什么尺寸?恐怕我太新手了,无法理解该页面上的信息。我不知道如何实现它。在语义和技术上,LONGBLOB比LONGTEXT更合适。
tinymce.init({
  selector: 'textarea',  // change this value according to your HTML
  images_upload_handler: function (blobInfo, success, failure) {
    var xhr, formData;

xhr = new XMLHttpRequest();
xhr.withCredentials = false;
xhr.open('POST', 'postAcceptor.php');

xhr.onload = function() {
  var json;

  if (xhr.status != 200) {
    failure('HTTP Error: ' + xhr.status);
    return;
  }

  json = JSON.parse(xhr.responseText);

  if (!json || typeof json.location != 'string') {
    failure('Invalid JSON: ' + xhr.responseText);
    return;
  }

  success(json.location);
};

formData = new FormData();
formData.append('file', blobInfo.blob(), blobInfo.filename());

xhr.send(formData);
  }});