How do I make multiple file upload as the on in Gmail?

Hi,

I am quite new to RoR, and now I am working on a muliple file-upload
page. I want to make one very similar to the one in Gmail.

Here is the code I wrote:

In the controller:

session[:upload_count] = 0 if request.get?

def attach
session[:upload_count] += 1
render :layout => false
end

def remove
render :nothing => true
end

In the view:
#compose.rhtml

<%= link_to_remote 'Attach image', :update => 'upload', :url => {:action => 'attach'}, :position => 'before' %>

#attach.rhtml

> <%= file_column_field "image[#{session[:upload_count]}]", "image" %> <%= link_to_remote 'remove', :update => "image#{session[:upload_count]}", :url => {:action => 'remove'} %>

Here is the problem, the attach function works fine, but when the remove
function is called, it only removes the last file field instead of the
proper one. I guess that’s because the link_to_remote tag gets
parameters dynamically here. So is there any way to solve this? Do I
have to use rjs?

One more question, I believe there is some better way other than using
session to store the upload_count variable, but I cannot find one, could
anyone give me a hint?