我正在尝试重命名上传图片
Permission denied @ sys_fail2 - (D:/RoR/projects/grp/public/uploads/gallery/test.jpg, D:/RoR/projects/grp/public/uploads/gallery/QINSNVZICC20160509132021.jpg)
我的代码:
photo = params[:gallery][:gal_img]
name = photo.original_filename
directory = "#{Rails.root}/public/uploads/gallery/"
path = File.join(directory, name)
uniq_name = (0...10).map { (65 + rand(26)).chr }.join
time_footprint = Time.now.to_formatted_s(:number)
File.open(path, "wb") do |file|
new_file_name = uniq_name + time_footprint + File.extname(file)
file.write(photo.read)
@uniq_path = File.join(directory, new_file_name)
File.rename(file, @uniq_path)
end
我已经检查并在我的ruby目录中提供了所有privilege
。
请告诉我为什么我会收到Permission denied
错误?