【问题标题】:Save cropped image to local server and it URL to MySQL database将裁剪后的图像保存到本地服务器,并将其 URL 保存到 MySQL 数据库
【发布时间】:2015-05-11 07:04:10
【问题描述】:

我正在使用cropit 来裁剪图像。

  <body>
    <div class="image-editor">
      <input type="file" class="cropit-image-input">
      <!-- .cropit-image-preview-container is needed for background image to work -->
      <div class="cropit-image-preview-container">
        <div class="cropit-image-preview"></div>
      </div>
      <div class="image-size-label">
        Resize image
      </div>
      <input type="range" class="cropit-image-zoom-input">
      <button class="export">Save</button>
    </div>

    <script>
      $(function() {
        $('.image-editor').cropit({
          exportZoom: 1.25,
          imageBackground: true,
          imageBackgroundBorderWidth: 10,
          imageState: {
            src: '../image/default-avatar.png'
          }
        });

        $('.export').click(function() {
          var imageData = $('.image-editor').cropit('export');
          window.open(imageData);

        });
      });
    </script>
  </body>

我遇到了两个问题:

  1. 当我进行裁剪并单击保存按钮时,裁剪后的图像会在新窗口中打开。我希望它不应该在新窗口中打开,而是应该将裁剪后的图像保存到相关的用户文件夹中,例如: ROOT_PATH.'user/upload/'.$row['UserName'].'/avatar/big/'
  2. 我还想在AvatarImage 列中保存要保存在 MySQL 数据库中的最新裁剪图像 URL。

在下面找到 MySQL 数据库信息:

数据库名称:ara

数据库用户:root

数据库密码:

数据库地址:127.0.0.1

【问题讨论】:

    标签: php mysql image


    【解决方案1】:

    您必须使用 php 对 base64 图像文件进行编码,并将图像保存到文件目录中, 请尝试像这个链接一样欺骗现有的

    How to create and save image to a website folder from a base64 encoded data/string using PHP

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-30
      • 2011-12-04
      • 2017-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多