Skip to content

Instantly share code, notes, and snippets.

@mloberg mloberg/upload.rb
Created Dec 16, 2011

Embed
What would you like to do?
qq.FileUploader Ruby
directory = './tmp/'
# ajax upload
if params[:qqfile].class == String
name = params[:qqfile]
string_io = request.body
data_bytes = string_io.read
path = File.join(directory, name)
File.open(path, "w") do |f|
f.write(data_bytes)
end
# regular upload
else
name = params[:qqfile][:filename]
path = File.join(directory, name)
File.open(path, "wb") do |f|
f.write(params[:qqfile][:tempfile].read)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.