diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb
index d321c2a8688c6f79fc0c6ec01a4d703eab66643c..40af7af5976163213221b0afff87c27287f64b1b 100644
--- a/app/controllers/photos_controller.rb
+++ b/app/controllers/photos_controller.rb
@@ -71,6 +71,7 @@ class PhotosController < ApplicationController
 
         respond_to do |format|
           format.json{ render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
+          format.html{ render(:layout => false , :json => {"success" => true, "data" => @photo}.to_json )}
         end
       else
         respond_with @photo, :location => photos_path, :error => message
@@ -214,6 +215,11 @@ class PhotosController < ApplicationController
   private
 
   def file_handler(params)
+    # For XHR file uploads, request.params[:qqfile] will be the path to the temporary file
+    # For regular form uploads (such as those made by Opera), request.params[:qqfile] will be an UploadedFile which can be returned unaltered.
+    if not request.params[:qqfile].is_a?(String)
+      params[:qqfile]
+    else
       ######################## dealing with local files #############
       # get file name
       file_name = params[:qqfile]
@@ -235,5 +241,6 @@ class PhotosController < ApplicationController
       Tempfile.send(:define_method, "content_type") {return att_content_type}
       Tempfile.send(:define_method, "original_filename") {return file_name}
       file
+    end
   end
 end
diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb
index 160373bf6470610eab5ae2085f5f37746985a58e..a24525534191431ffa5f730ab682f7cf387a659a 100644
--- a/app/controllers/publics_controller.rb
+++ b/app/controllers/publics_controller.rb
@@ -3,7 +3,7 @@
 #   the COPYRIGHT file.
 
 require File.join(Rails.root, 'lib', 'stream', 'public')
-require 'newrelic_rpm' if File.exists?(File.expand_path('../newrelic.yml', __FILE__))
+require 'newrelic_rpm' if File.exists?(File.expand_path("#{Rails.root}/config/newrelic.yml", __FILE__))
 
 class PublicsController < ApplicationController
   require File.join(Rails.root, '/lib/diaspora/parser')
@@ -11,7 +11,7 @@ class PublicsController < ApplicationController
   require File.join(Rails.root, '/lib/postzord/receiver/private')
   include Diaspora::Parser
 
-  newrelic_ignore if File.exists?(File.expand_path('../newrelic.yml', __FILE__))
+  newrelic_ignore if File.exists?(File.expand_path("#{Rails.root}/config/newrelic.yml", __FILE__))
 
   skip_before_filter :set_header_data
   skip_before_filter :which_action_and_user
diff --git a/public/javascripts/fileuploader-custom.js b/public/javascripts/fileuploader-custom.js
index d5844a7c75163eaa98f4d3a37207c3438c39fa8c..1840b14fa8b204b52e7d87694333111757def9ff 100644
--- a/public/javascripts/fileuploader-custom.js
+++ b/public/javascripts/fileuploader-custom.js
@@ -1017,6 +1017,7 @@ qq.extend(qq.UploadHandlerForm.prototype, {
         var iframe = this._createIframe(id);
         var form = this._createForm(iframe, params);
         form.appendChild(input);
+        $(form).append($('<input type="hidden" name="authenticity_token" value="'+$("meta[name='csrf-token']").attr("content")+'"/>'));
 
         var self = this;
         this._attachLoadEvent(iframe, function(){
diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb
index fdafd0905f90eba522936ec498a72904b622f6bf..957c9915777ca26390ace0c0544ccb26bb777794 100644
--- a/spec/controllers/photos_controller_spec.rb
+++ b/spec/controllers/photos_controller_spec.rb
@@ -13,6 +13,28 @@ describe PhotosController do
     sign_in :user, alice
     request.env["HTTP_REFERER"] = ''
   end
+  
+  describe '#create' do
+    before do
+      @params = {:photo => {:aspect_ids => "all"}, :qqfile => Rack::Test::UploadedFile.new("spec/fixtures/button.png", "image/png") }
+    end
+    
+    it 'accepts a photo from a regular form submission' do
+      lambda {
+        post :create, @params
+      }.should change(Photo, :count).by(1)
+    end
+    
+    it 'returns application/json when possible' do
+      request.env['HTTP_ACCEPT'] = 'application/json'
+      post(:create, @params).headers['Content-Type'].should match 'application/json.*'
+    end
+    
+    it 'returns text/html by default' do
+      request.env['HTTP_ACCEPT'] = 'text/html,*/*'
+      post(:create, @params).headers['Content-Type'].should match 'text/html.*'
+    end
+  end
 
   describe '#create' do
     before do