修改文件上传目录
easy_fckeditor默认的文件上传目录为
public/uploads/Image,全部上传的图片都会被上传的该目录下,为了方便管理,将上传的图片根据上传日期上传到不同的日期目录下:
需要修改几个方法:
def current_directory_path
base_dir = "#{UPLOADED_ROOT}/#{params[:Type]}/#{ Time.now.strftime('%Y%m%d') }"
# Dir.mkdir(base_dir, 0775) unless File.exists?(base_dir)
FileUtils.mkdir_p base_dir
check_path("#{base_dir}#{params[:CurrentFolder]}")
"#{base_dir}"
end
def upload_directory_path
# uploaded = request.relative_url_root.to_s + "#{UPLOAD_FOLDER}/#{params[:Type]}"
uploaded = ActionController::Base.relative_url_root.to_s+"#{UPLOADED}/#{params[:Type]}" + "/" + Time.now.strftime('%Y%m%d')
"#{uploaded}#{params[:CurrentFolder]}"
end
主要是加个日期
Time.now.strftime('%Y%m%d'),将上传后的图片上传到public/uploads/Image/20090403/目录下,如果要换另一种形式,也很方便 ,将
Time.now.strftime('%Y%m%d')改成自己需要的就可以了。