Upload progress problem with Ajax component


#1

All,

I believe that I’ve set up an upload progress bar correctly. When I do
my upload, the initial status message appears on the screen, and when
the upload finishes, the finish message appears on the screen. However,
in between, the status bar is not updating. So my progress bar starts
out with 0% filled in, and then, when the upload completes, it’s 100%
filled in.

Environment:

Windows XP
WEBrick 1.3.1
Rails 1.0
Prototype 1.4
script.aculo.us 1.5.3

I did some debugging and it appears that the Ajax updater call happens
twice after I initiate the upload action, and then no more calls to
upload_status occur. However, when the upload completes, then all of
the Ajax updater calls begin to happen per the degradation schedule.
Also, when the save_HTML (the actual upload method) completes, the view
save_HTML.rhtml does not get called.

It’s like something gets stuck and doesn’t return control back to the
browser when it should and therefore the progress bar can’t be updated.

I’m not sure what is wrong here - whether there is a genuine Javascript
problem or whether I am not returning control to my page correctly.
Here are some code snippets

upload.rhtml:
<%= form_tag_with_upload_progress(
{ :action => ‘save_HTML’ },
{ :begin => ‘do_start()’,
:finish => ‘do_finish(arguments[0])’,
:frequency => 5 }) %>
<%= file_field ‘eSimplyJob’, ‘file’ %>

<%= submit_tag "Upload" %>

<%= upload_status_tag %> <%= end_form_tag %>

In my controller: upload_status_for :save_HTML

save_HTML (in controller):
public
def save_HTML
@filename = @params[:eSimplyJob][:file].original_filename
File.open("#{RAILS_ROOT}/htmlfiles/#{@filename}", “wb”) do |f|
f.write(@params[:eSimplyJob][:file].read)
end
puts “Finished with save_HTML”
end

upload_status (in controller):
public
def upload_status
puts ‘Called upload status…’
render :inline => “”,
:layout => false
end