# How to create a progress bar and status messages?

**URL:** <https://www.ruby-forum.com/t/how-to-create-a-progress-bar-and-status-messages/157288>\
**Category:** Rails\
**Created:** [January 9, 2009, 7:13am UTC](https://www.ruby-forum.com/t/how-to-create-a-progress-bar-and-status-messages/157288 "2009-01-09T07:13:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [January 9, 2009, 7:13am UTC](https://www.ruby-forum.com/t/how-to-create-a-progress-bar-and-status-messages/157288/1 "2009-01-09T07:13:08Z")

</div>

Dear all,

Iam working on video gallery and i have created a file uploading  
page(add.rhtml), list page which lists all uploaded video files.

In uploading, i have used ffmpeg tool to convert all movie files into  
flash files and also i have used ffmpeg tool to take thumbnails. Could  
anyone please suggest about the methods to create a progess bar for this  
functionality.

As my form is not an ajaxified form, i need to know how to create a  
progress bar and displaying the satus of progreess like,

1. Uploading in Progress
2. File uploaded sucessfully, conversion of movie file to flash file in  
progress
3. Conversion of files done successfully, thumbnail generation in  
progress
4. sucess.

So along with a progress bar it should display the above texts, in each  
process. Please suggest me a way to do?

my add.rhtml

\<%= flash.now[:notice] %\>

\<% form\_for(:videos, :html =\> {:multipart =\> true}) do |f| %\>

```
Caption <%= f.text_field 'caption' %><br/><br/>

Image <%=file_field("image","blob")%><br/><br/>

Description <%= f.text_area :description, :size => "25x3"%>

```

```
<%= f.select :category_id,
  Category.find( :all ).collect {|c| [c.category_name, c.id] }

```

%\>

\<%= submit\_tag “uploadfile”, :url =\> {:action =\> ‘add’}, :class =\>  
‘submit’ %\>

\<%end %\>

My controller(videos\_controller)

def add  
#----

```
if request.post? and params[:videos] and params[:image][:blob]
@video = Video.new(params[:videos])
video = params[:image][:blob]
if video == ''
   flash[:notice] = "Please browse a video file"
else
   video_name=params[:image][:blob].original_filename
   video_size = params[:image][:blob].size/1024
   @video.video_size = video_size
   videoname = video_name.split('.')[0]
   videoname_type = video_name.split('.')[1]
   if videoname_type == 'flv' or videoname_type == 'swf'
      @video.video = video_name
      if @video.save
         File.open(RAILS_ROOT + "/public/videos/" + video_name ,

```

“wb”) do |f|  
f.write(video.read)  
system “ffmpeg -itsoffset -4 -i  
public/videos/#{video\_name} -vcodec mjpeg -vframes 1 -an -f rawvideo -s  
160x120 public/images/thumbs/#{videoname}.jpg”  
end  
end  
if File.exists? RAILS\_ROOT + “/public/videos/” + video\_name  
and  
File.exists? RAILS\_ROOT +  
“/public/images/thumbs/#{videoname}.jpg”  
redirect\_to :action =\> ‘list’  
end  
else  
videoname = video\_name.split(’.’)[0]  
@video.video = videoname+".flv"  
if @video.save  
File.open(RAILS\_ROOT + “/public/videos/” + video\_name ,  
“wb”) do |f|  
f.write(video.read)  
flash[:notice] = “conversion of movie file to flash file  
in progress”  
if system “ffmpeg -i public/videos/#{video\_name} -ar 44100  
public/videos/#{videoname}.flv”  
system “ffmpeg -itsoffset -4 -i  
public/videos/#{videoname}.flv -vcodec mjpeg -vframes 1 -an -f rawvideo  
-s 160x120 public/images/thumbs/#{videoname}.jpg”

```
        else

          flash[:notice] = "Video format is not supported"

        end
      end
      if File.exists? RAILS_ROOT + "/public/videos/" + video_name

```

and  
File.exists? RAILS\_ROOT +  
“/public/images/thumbs/#{videoname}.jpg”  
if File.delete(“public/videos/#{video\_name}”)  
redirect\_to :action =\> ‘list’

```
      end
      else
         redirect_to :action => 'list'
      end
    end
  end

```

end  
end  
end

Thanks in advance

Regards,  
Martin

---

<div class="post-metadata">

**Author:** ![martin\_mercy2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d2c977/32.png) [@martin\_mercy2001](https://www.ruby-forum.com/u/martin_mercy2001)\
**Post date:** [January 10, 2009, 7:30am UTC](https://www.ruby-forum.com/t/how-to-create-a-progress-bar-and-status-messages/157288/2 "2009-01-10T07:30:46Z")

</div>

could anyone help me to solve tha above task, i need to create progress  
bar for all functionality s together like uploading and ffmpeg  
functions. So please anyone suggest me how to implement a new progress  
bar with ajax concept.

regards,  
Martin
