主要应用的是ruby中的%x——执行外部的程序。
主要的代码:
程序代码
def upload_images_now
#获得网站绝对路径
root_path = File.expand_path(RAILS_ROOT)
#删除之前上传的文件
%x"del #{root_path}/public/uploads/picture.rar"
#将上传的文件保存到uploads文件夹中
File.open("#{RAILS_ROOT}/public/uploads/picture.rar", "wb") {|f| f.write(params['rarfile'].read)}
#调用rar.exe,释放到/images文件夹
@result = %x"#{root_path}/rar.exe e #{root_path}/public/uploads/picture.rar -w #{root_path}/public/images"
end
主要的代码:
程序代码
def upload_images_now
#获得网站绝对路径
root_path = File.expand_path(RAILS_ROOT)
#删除之前上传的文件
%x"del #{root_path}/public/uploads/picture.rar"
#将上传的文件保存到uploads文件夹中
File.open("#{RAILS_ROOT}/public/uploads/picture.rar", "wb") {|f| f.write(params['rarfile'].read)}
#调用rar.exe,释放到/images文件夹
@result = %x"#{root_path}/rar.exe e #{root_path}/public/uploads/picture.rar -w #{root_path}/public/images"
end



选择表情