Multiple image upload

Hello All,

I have a requirement.

I am uploading multiple images from a folder.

After Submit, it should show all the images row-wise in the UI in the same page as :-

Image Name : name.png

Image Name : hello.png etc…

How can I achieve this?

Thanks,

Avi

Which bit don't you know how to do? Upload? Redirect to the correct
view after upload? Fetch names from db in controller action? View
the names?

We are not telepathic, you must ask specific questions not just ask us
how to write your application.

Colin

Upload is fine.

Suppose I am uploading five images, which I can do with file upload.

But I also need to upload those images to a specific category. I also need to save Image name and which category(dropdown) it belongs into the db.

Suppose I uploaded 2 images:-

After clicking on submit, I will get :-

Image , Image Name : Text(We have to input), Category : Dropdown ---- It will repeat

Can anyone help me on this ?

Can anyone help me on this ?

You still have not really explained the problem. Start with just one
problem that you want to solve. Don't ask a general question,
describe exactly what you want to do and what the problem is.
Remember, start with just the first thing you are having a problem
with. Once that is sorted you can move on to the next problem.

Colin

My Solution is :

add category field in table

at the time of uploading create a folder having name of category and store that image in the respective category

For ex:

if you are uploading image belongs to school_pics category

create a folder school_pics and store the respective images in that folder

if params[:category].eql?(‘school_pics’)

blah blah

else

blah blah blah

end

Upload is fine.
Suppose I am uploading five images, which I can do with file upload.
But I also need to upload those images to a specific category. I also need to save Image name and which category(dropdown) it belongs into the db.

Suppose I uploaded 2 images:-
After clicking on submit, I will get :-

Image , Image Name : Text(We have to input), Category : Dropdown ---- It will repeat

Are you trying to assign these attributes after the file is uploaded, or at the same time that you upload it? I usually follow this pattern (pseudocode!!):

class Article < ActiveRecord::Base
  has_many :images, :dependent => :destroy
  accepts_nested_attributes_for :images
...
end
class Image < ActiveRecord::Base
  belongs_to :article
...
end

Image can have all the unique attributes -- filename, uuid, whatever else is needed by your chosen attachment library (Dragonfly, Paperclip, CarrierWave) along with the category, caption, anything else you need in your application.

Using Ryan Bates' nested_form Action, you can add as many of these as you want at the time you create or edit the parent object. I recommend a quick view of the associated RailsCast: http://railscasts.com/episodes/196-nested-model-form-part-1 and http://railscasts.com/episodes/197-nested-model-form-part-2

The upshot of this construction is that you can attach as many rich (decorated) children to the parent as you need, and each one will be fully populated in a single form submission. You won't need to come back and edit the children to add the metadata to the file later (although you can if you really want to).

Walter

I want to something like - http://blueimp.github.com/jQuery-File-Upload/

So first I just want to show images in the UI. Then I want to edit & update it into database.

I was also thinking alternative as :-

Save all the images into the model database. Then edit all its content.

Ex -> Through fileupload, I will save all images in db. & redirect that page to show page of the images, where I can edit its content.

Again, what’s your question? You seem to have posted a question, described what you want, then also how you would solve it - by saving all images and then editing their content. I really don’t see a topic for discussion here.