class FilesController < ApplicationController
	skip_before_action :verify_authenticity_token

	def upload
	    uploaded_file = params[:upload]
	    filename = "ntsclinic-#{SecureRandom.hex(8)}#{File.extname(uploaded_file.original_filename)}"
	    File.open(Rails.root.join('public', 'uploads/posts', filename), 'wb') do |file|
	      file.write(uploaded_file.read)
	    end
	    render json: {url: root_url(:only_path => false)+"uploads/posts/#{filename}"}
	end

end