使用TinyMCE发布的图像是否有尺寸限制?

问题描述 投票:0回答:3

我正在一个包含博客类型部分的网站上工作。我有一个发布系统,其中来自编辑器的输入被发送到mysql数据库表。到目前为止,除了添加本地图像时,所有其他操作都有效。如果图像具有非常小的文件大小,则该图像有效,否则它将不显示,有时会清除$ _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的js代码:

tinymce.init({
/* replace textarea having class .tinymce with tinymce editor */
selector: "textarea.tinymce",

/* force_p_newlines : false,
force_br_newlines : true, */

/* theme of the editor */
theme: "modern",
skin: "lightgray",

/* width and height of the editor */
width: "100%",
height: 300,

/* display statusbar */
statubar: true,

/* plugin */
plugins: [
    "advlist autolink link image lists charmap print preview hr anchor pagebreak",
    "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
    "save table contextmenu directionality emoticons template paste textcolor"
],

/* toolbar */
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media fullpage | forecolor backcolor emoticons",

/* enable title field in the Image dialog */
image_title: true,
/* enable automatic uplaods of images represented by blob or data URIs */
automatic_uploads: true,
/* add custom file picker only to image dialog */
file_picker_types: 'image',
file_picker_callback: function(cb, value, meta) {
    var input = document.createElement('input');
    input.setAttribute('type', 'file');
    input.setAttribute('accept', 'image/*');

    input.onchange = function() {
      var file = this.files[0];
      var reader = new FileReader();

      reader.onload = function () {
        var id = 'blobid' + (new Date()).getTime();
        var blobCache =  tinymce.activeEditor.editorUpload.blobCache;
        var base64 = reader.result.split(',')[1];
        var blobInfo = blobCache.create(id, file, base64);
        blobCache.add(blobInfo);

        // call the callback and populate the Title field with the file name
        cb(blobInfo.blobUri(), { title: file.name });
      };
      reader.readAsDataURL(file);
    };

    input.click();
}
});
mysql image upload tinymce filesize
3个回答
1
投票

我面临相同的问题,通过将列类型从TEXT更改为LONGTEXT解决>]


0
投票

TinyMCE已经可以处理插入本地图像并将其发送到服务器的方法:


0
投票

与其将图像保存在数据库中,不如将它们另存为文件夹中的文件更好。根据tinymce文档,可以使用两种方法在服务器中上传图像。

© www.soinside.com 2019 - 2024. All rights reserved.