MK, 
     Make sense...  So, create a page  like below. Unfortunately, I tried this 
and it does not work because %init and %perl are only execute after the 
complete file has been transfer to the server.  So, call to file size always 
match total size.. This is even true for very large files ...

<%args>
  $filepath 
  $totalsize  
</%args>

<%init>
  #attempt to read the file size of filepath unfortunately...   
  # This is not execute until the complete file has been upload..
</%init>

<%perl>
  #attempt to read the file size of filepath unfortunately...
  # This is not execute until the complete file has been upload..
</%perl>
-----Original Message-----
From: MK [mailto:halfcountp...@intergate.com] 
Sent: Wednesday, November 10, 2010 4:20 PM
To: Scott Dolan
Cc: Mason-users@lists.sourceforge.net
Subject: Re: [Mason] Mason File Upload Progress Bar

On Wed, 10 Nov 2010 20:39:31 +0000
Scott Dolan <sdo...@v12groupinc.com> wrote:
> Thanks MK, 
>   But, I am looking for a pure mason and ajax and/or jquery solution.  
> I am currently have a solution similar to pastebin work using CGI and 
> ajax.

I think you do not understand, sorry if I was not clear.  Suggestion #2 is pure 
mason with ajax (which would be the best way to do it).  

Nb, jQuery is just a javascript library that (in part) implements "ajax" 
methods (you can also write them yourself, but most people will recommend 
against this because of hassles with maintenance, different browsers, etc). 
"Ajax" itself is just conceptual:

http://en.wikipedia.org/wiki/Ajax_(programming)

It exploits the *client side* potential of javascript, which (short of flash, 
et. al.) is necessary for communicating with the server and modifying page 
content without replacing the entire page. 

Anyway, lemme try and explain that second suggestion again:

1) You write a mason script that accepts two parameters, a filepath and a total 
size.  This page checks the current size of the file on the server, and turns 
that into a percentage of the total size.  This is used to create the html 
mark-up for the progress bar, which is what that .mhtml file creates (so it's 
not a complete html page, it's just a partial "component").

2) Your file upload page fires a javascript rountine on submit that uses 
setInterval (a standard javascript function) to poll the server, via some AJAX 
method, every 1000 milliseconds.  The ajax call is to the mason page from #1.  
It receives fresh html from the mason component which you use to update 
(replace) the progress bar, so that it reflects the size of the file on the 
server.

So, that's just a mason page and some javascript (probably making use of a 
library such as jQuery).  Make sense?

MK

--
"The angel of history[...]is turned toward the past." (Walter Benjamin)

------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to