#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    9
    Rep Power
    0

    Update progress bar with CGI in C


    Hi!

    Trying to upload file with cgi in C and show file uploading with progress bar. Uploading file with cgi works fine, but have problem with refreshing progress bar control.

    This is client html code:
    <!DOCTYPE html>
    <html> <head> </head>
    <body>

    <form ENCTYPE="multipart/form-data" method="POST" action="http://localhost/homecgi/progress.exe">
    Name: <input type="text" name="first_name" value="John" /> <br />
    <INPUT NAME="fileupload" TYPE="file" multiple/> <BR>
    <input type="submit" name="action" value="Submit" />
    </form>

    </body>
    </html>
    In cgi script trying to upload file and with every byte read refresh progress bar value:
    ...
    int i = 0, n, zb;

    printf(" <progress id='progressBar1' value='0'></progress> <br>");

    printf("<script>");
    printf(" document.getElementById('progressBar1').max = %d; ", content_length);
    printf("</script>");

    while(i<content_length){
    n = fread(s_content, 1, 1, stdin);
    zb += n;

    printf("<script>");
    printf(" document.getElementById('progressBar1').value = %d; ", zb);
    printf("</script>");

    fflush(stdout);
    i++;
    }
    ...
    Server sends new progress bar value to client, but when there is to much bytes of uploading file, more then 10kB, client cant render progress bar, and get stuck with: CGI Timeout The specified CGI application exceeded the allowed time for processing. The server has deleted the process.

    On server side is embedded http server with only cgi. On client side html5, css and javascript.
    Any suggestions! Maybe some other way to deal with this stuff?
    Thanks
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    Sounds like an issue with your http server configuration. You need to configure your http server to increase the timeout for CGI scripts.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    9
    Rep Power
    0
    Maybe it is problem because im trying to update progress bar with every byte read by server in loop. Is it too much
    for server to render page after each byte? Is it at all possible to do this update progress bar only with cgi, html5 and javascript?

    Anyone!?

IMN logo majestic logo threadwatch logo seochat tools logo