Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6893579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:40:35+00:00 2026-05-27T06:40:35+00:00

I am using Rails Carrier Wave with JQuery Upload like on this rails tutorial

  • 0

I am using Rails Carrier Wave with JQuery Upload like on this rails tutorial, but I am having an error when I hit the upload button :

Error: SyntaxError: JSON.parse

Any advise/suggestions are much appriciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:40:35+00:00Added an answer on May 27, 2026 at 6:40 am

    Why not try Uploadify?

    Step 1

    Add gem 'carrier_wave' to you Gemfile.

    Step 2

    Save this code to /lib/flash_session_cookie_middleware.rb:

    require 'rack/utils'
    
    class FlashSessionCookieMiddleware
      def initialize app, session_key = '_session_id'
        @app = app
        @session_key = session_key
      end
    
      def call env
        if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
          request = Rack::Request.new env
          env['HTTP_COOKIE'] = [@session_key, request.params[@session_key]].join('=').freeze unless request.params[@session_key].nil?
          env['HTTP_ACCEPT'] = "#{request.params['_http_accept']}".freeze unless request.params['_http_accept'].nil?
        end
    
        @app.call env
      end
    end
    

    Step 3

    Edit session_store.rb and add this code to the end of file:

    Rails.application.config.middleware.insert_before(
      ActionDispatch::Session::CookieStore,
      FlashSessionCookieMiddleware,
      Rails.application.config.session_options[:key]
    )
    

    Step 4

    Download Uploadify and unzip it.

    Step 5

    1. Copy jquery.uploadify.v2.1.4.min.js and swfobject.js to
      /app/assets/javascripts if you use Rails 3.1 or later; to
      /public/javascripts if you use Rails 3.0 or an earlier version.
    2. Copy uploadify.swf and cancel.png to /app/assets/images/ or
      /public/images.
    3. Copy uploadify.css to /app/assets/stylesheets/ or
      /public/stylesheets.

    Step 6

    Edit your application.js and insert below:

    //= require swfobject
    //= require jquery.uploadify
    

    Step 7

    In you upload page, add this:

    <input id="uploadify" name="uploadify" type="file"/>
    

    Step 8

    Add this code to you upload script:

    $(document).ready(function() {
      <% key = Rails.application.config.session_options[:key] %>
      var uploadify_script_data = {};
      var csrf_param = $('meta[name=csrf-param]').attr('content');
      var csrf_token = $('meta[name=csrf-token]').attr('content');
      uploadify_script_data[csrf_param] = encodeURI(encodeURIComponent(csrf_token));
      uploadify_script_data['<%= key %>'] = '<%= cookies[key] %>';
    
      $('#uploadify').uploadify({
        uploader        : '/assets/uploadify.swf',
        script          : '/photos',
        cancelImg       : '/images/cancel.png',
        auto            : true,
        multi           : true,
        removeCompleted     : true,
        scriptData      : uploadify_script_data,
        onComplete      : function(event, ID, fileObj, doc, data) {
        }
      });
    });
    

    Step 9

    Write your controller like this:

    def create
      @photo = Photo.new image: params[:file_data]
      @photo.save
    end
    

    Note: This was tested with Uploadify 2.1.4.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using rails, but doing all my Javascript unobtrusively using jQuery in application.js .
Using Rails I'm trying to get an error message like The song field can't
Using Rails 2.3.8. I have added this in my controller: filter_parameter_logging :password, :password_confirmation But
I am having problem uploading image to mongodb using rails and carrierwave. This is
I am using Rails and jQuery, making an ajax call initiated by clicking a
I'm making a rails 3.1 app using carrierwave to upload files to aws s3.
Using Rails 3.2.0 with haml and sass: I Would like to link an external
Using Rails, I would like to add: <span class='req'>&bull;</span> within my <label> tags in
I am using Rails 2.2.2 and I would like to add an id to
I am using rails 3.1rc4 with paperclip and i cannot upload any image file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.