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 6779461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:23:16+00:00 2026-05-26T16:23:16+00:00

I am trying to create a photo upload function for a website, and there

  • 0

I am trying to create a photo upload function for a website, and there are two ways to upload. One is by specifying a remote url link, another is by uploading from local computer. So this requires me to write two partials. What’s an efficient way to create a photo_upload view with two links to the two situations above, using the same controller for photo? I am stuck on how to pass the redirection information to the controller. Ideally I want to set a photocontroller variable called upload_source when I click on one of the links, but I don’t know how to use link_to to pass such variable and where would be the best place to define this boolean variable.

Some code examples:

from the view:

  <h2>Upload a Photo: Step 1 of 3</h2>
    <br>
    <h3><strong>Where is your photo?</strong></h3>
    <br>
    <div class="button_border">
      <a href="add_photo_web">On the Web</a>
    </div>
    <div class="button_border">
      <%= link_to "On My Computer", new_photo_path%>
    </div>
  </div>

From photoController (not sure if this is the right thing to do):

  helper_method :get_source, :set_source

  private

  def set_source=(_source)
    @@source = _source
  end  

  def get_source
    @@source
  end 

Helps are greatly appreciated!

Thank you all for very generous help! I am constantly amazed by the efficiency of stackoverflow.

  • 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-26T16:23:17+00:00Added an answer on May 26, 2026 at 4:23 pm

    If I understand you correctly, you could achieve what you want by having links defined like this:

    link_to "On my computer", new_photo_path, :source => "local"
    link_to "Remote source", new_photo_path, :source => "remote" 
    

    and then in the controller you could have something like:

    def new
     if params[:source] == "local"
       render :partial => 'local'
     else
       render :partial => 'remote'
     end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to upload a photo to one of my albums on facebook, with
js.I am trying to create a file upload using node.js and mongodb.I am getting
I'm trying to have a user upload a file and then my function will
I am trying to upload a photo using the API and am having an
I am trying to create a system that enables the admin to upload a
I'm trying to create a dynamic path for when my users upload images. It
I'm trying to create thumbnails (288x288) of selected photos from iPad photo library. I
I'm trying to create a photo based app and I want to be able
I have a function in which I'm trying to resize a photo twice from
I'm trying to create a little ajax photo album with text description... now I've

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.