zoukankan      html  css  js  c++  java
  • ruby -- 进阶学习(五)使用Ckeditor插件上传中文图片

    基于rails4.0环境

    当使用Ckeditor上传中文命名图片时报错,解决方法是对图片进行重命名

    在Ckeditor插件的安装目录下找到controllers/.../application.rb

    比如:E:RailsInstallerRuby1.9.3lib ubygems1.9.1gemsckeditor-4.0.4appcontrollersckeditorapplication.rb

    然后找到 def respond_with_asset(asset)

    1 def respond_with_asset(asset)      
    2       file = params[:CKEditor].blank? ? params[:qqfile] : params[:upload]
    3       asset.data = Ckeditor::Http.normalize_param(file, request)
    4     ……
    5 end

    修改如下:

    1 def respond_with_asset(asset)  
    2       file = params[:CKEditor].blank? ? params[:qqfile] : params[:upload]
    3       extension = File.extname( file.original_filename.to_s).downcase
    4       file.original_filename .replace(Time.now.strftime("%Y%m%d%H%M%S")+rand(10000).to_s+extension)    
    5       asset.data = Ckeditor::Http.normalize_param(file, request)
    6      ……
    7 end
  • 相关阅读:
    四、K8S
    三、kubernetes环境搭建(实践)
    二、K8S镜像问题
    一、linux扩展
    十、docker扩展
    二、kubernetes环境搭建
    一、Composer
    一、权限控制-过滤器
    二、kubernetes
    【2019-06-28】客观认知
  • 原文地址:https://www.cnblogs.com/lmei/p/3249466.html
Copyright © 2011-2022 走看看