Menu

#16 problems with progress.php

open
nobody
None
5
2004-12-28
2004-12-28
No

I just downloaded the latest version and noticed there
was a progress.php file which could be used instead of
the progress.cgi file which suits me fine.

However when using I came across the following
oversights which you might like to fix for the next
distribution.

1. Start time not working therefore all calculations are
incorrect.

Solution: Either change the variable being used in the
progress.php file for start_time or pass over from the
pgbar.php file the start_time variable as shown below:

$link = ("progress.php?
iTotal=".$iTotal."&iRead=".$iRead."&iStatus=".$iStatus."&s
essionid=".$sessionId."&dtnow=".$dtnow."&dtstart=".$dts
tart."&start_time=".$dtstart);

2. Upload speed figures do not calculate the same as
with the cgi version

Solution: After this line:

$speed = ($current_size / $time_elapsed);

add the following:

$bitSpeed = $speed * 8; # bps
$kbitSpeed = $bitSpeed / 1000; # Kbps
$bSpeedf = sprintf("%d",$kbitSpeed); # remove decimals

and then reference the $bSpeedf instead of $speed in
the html being displayed.

3. There did not appear to be any cleanup of the
temporary files being created.

Solution: Add this at the end of the file:

if ($percent_done >= 100){
unlink("/tmp/{$sessionid}_flength");
unlink("/tmp/{$sessionid}_postdata");
unlink("/tmp/{$sessionid}_signal");
}

4. The refresh rate is hard coded and does not use the
$interval variable set in the header.cgi.

Solution: Either get it to use the interval or add a new
variable in the php file at the top eg
$the_refresh_interval = 1; and reference that

<meta http-equiv="refresh" content="<?
echo "$the_refresh_interval"; ?>;<? echo $_SERVER
['PHP_SELF']; ?>?total_size=<? echo $total_size; ?
>&start_time=<? echo $start_time; ?>&sessionid=<?
echo $sessionid; ?>">

On my version I have also added some if statements
that

1. change the File upload in Progress to File upload
completed.

2. If auto_close_window is required you change a
variable set at the top of the page to Y and then the
window will autoclose on completiong, otherwise it stays
open and a Close Window button appears at the bottom
when the upload has completed.

If you would like my version of progress.php to see the
changes and incorporate them if you wish please let me
know.

Apart from those minor points. Good job well done.

David Cochrane

Discussion

  • Michael Elsdoerfer

    Logged In: YES
    user_id=755086

    I'm trying for some time now to get the progress.php to
    work, and I would love to see how you've done it...

     
  • David Cochrane

    David Cochrane - 2004-12-28

    replacement pgbar.php file

     
  • David Cochrane

    David Cochrane - 2004-12-28

    Logged In: YES
    user_id=1184169

    miracle2k,

    I am not quite sure how this posting system works so I hope I
    manage to get whats required up. I am going to attach the
    progress.php and the pgbar.php files.

    The files attached carry no form of warranty or guarantee. I
    have added other bits and pieces in addtion to just getting it
    working.

    In addition you might light to use this slightly modified
    javascript functions in the upload.php file:

    function popUP(mypage, myname, w, h, scroll, titlebar)
    {

    var winl = (600-20 - w) / 2;
    var wint = 50;
    winprops
    = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbar
    s='+scroll+',resizable'
    win = window.open(mypage, myname, winprops)
    if (parseInt(navigator.appVersion) >= 4) {
    win.window.focus();
    }
    }

    function postIt()
    {

    if(check_types() == false)
    {
    return false;
    }
    baseUrl = postLocation;
    sid = document.forms['add_file'].sessionid.value;
    iTotal = escape("-1");
    baseUrl += "?iTotal=" + iTotal;
    baseUrl += "&iRead=0";
    baseUrl += "&iStatus=1";
    baseUrl += "&sessionid=" + sid;

    popUP(baseUrl,"Uploader",460,190,false,false);
    document.forms['add_file'].submit();
    }

    Hope this helps.

    David Cochrane

     
  • David Cochrane

    David Cochrane - 2004-12-28

    Logged In: YES
    user_id=1184169

    in the javascript posted I have based it on the form name
    being 'add_file'. If you are using a different form name on the
    upload.php file then you will need to change the instances
    of 'add_file' to your form name.

    Sorry for the confusion.

    David Cochrane

     
  • David Cochrane

    David Cochrane - 2004-12-29

    Logged In: YES
    user_id=1184169

    I have found that on some file uploads (not all) I get a server
    error. No idea why just yet but when and if I find out why
    these errors are occuring I will let you know.

    David Cochrane

     
  • Nobody/Anonymous

    Logged In: NO

    I will give your files a try - thanks David!

     
  • David Cochrane

    David Cochrane - 2004-12-30

    Logged In: YES
    user_id=1184169

    I think I found the reason for the error uploads and that was
    in the way the tidying up of thetemp files was being done.
    This also highlighted an error on the progress bar on larger file
    sizes. Basically by using the $percent_done variable as a
    trigger was not working as I think due to rounding it would
    show 100% before the file had completely uploaded.

    I have changed the variables used to trigger things to a
    combination of $current_size and the $total_size.

    This seems to have cured the problem and I have not had
    any errors since. I have uploaded a revised file (you will have
    to rename it to progress.php). Please note that I have

    <?php
    session_start();
    ?>

    at the top of the file to keep my session variables going. You
    may wish to remove the 3 lines if you are not using your own
    session variables. (I had troubles with the session variables
    getting lost on huge file uploads ie 150mb+).

    Please let me know if anybody experiences any problems with
    the latest progress(revised).php file

    David Cochrane

     
  • David Cochrane

    David Cochrane - 2004-12-31

    Latest progress.php file (needs renaming if used)

     
  • David Cochrane

    David Cochrane - 2004-12-31

    Logged In: YES
    user_id=1184169

    OK, 3rd time lucky. The revised file didn't like working with
    firefox so here is a version called progress(revised1).php
    which firefox can deal with.

    Sorry for the multiple versions (I have deleted all except for
    the last one)

    David Cochrane

     
  • Michael Elsdoerfer

    Logged In: YES
    user_id=755086

    I just tried to latest version. I just had to move the
    following piece of code up to the beginning of the file,
    because otherwhise $sessionid wouldn't be defined at the
    time the variables for the temporary files are assigned
    (with register_globals off), but apart from that, it works
    like a charm. Thanks!

    $started = TRUE;
    $total_size = $_GET['total_size'];
    $start_time = $_GET['start_time'];
    $time_now = time();
    $sessionid = $_GET['sessionid'];

    "at the top of the file to keep my session variables going. You
    may wish to remove the 3 lines if you are not using your own
    session variables. (I had troubles with the session variables
    getting lost on huge file uploads ie 150mb+)."

    You mean, you are using a session for stuff like login data,
    and it got lost?

     
  • David Cochrane

    David Cochrane - 2005-01-05

    Logged In: YES
    user_id=1184169

    "at the top of the file to keep my session variables going. You
    may wish to remove the 3 lines if you are not using your own
    session variables. (I had troubles with the session variables
    getting lost on huge file uploads ie 150mb+)."

    -- "You mean, you are using a session for stuff like login data,
    and it got lost? --"

    The upload script is a small part of a much larger programme I
    am writing and I am using session variables to store quite a
    few variables relating to the logged on individual. One of the
    variables being stored is used as part of a directory location
    which is used in the renaming of the temporary files being
    uploaded. For some reason on large file uploads which took a
    long time eg 3-4 hours when it came to relocate the temp file
    it lost the variable and was putting the file in the wrong
    location. I am aware that session variables should be there
    for the entire time that the browser session was active but
    thought perhaps due to some server setting or other setting I
    am aware of the session variables were being killed off. To try
    to overcome this I added those lines to hopefully keep the
    session active. I haven't had a chance to test to see if it has
    made any difference yet but will keep you updated.

    Thanks for the feedback

     
  • Nobody/Anonymous

    Logged In: NO

    eee

     

Log in to post a comment.