0

Hello.

I'm using a php script to upload file. I've used an iframe inserted on the upload page that refreshes every second/3sec. to display percentage uploaded.

forget percentage, lets take a simple example.

Presently, my iframe displays last two digits of PHP time() function that change constantly. If you see the live example at: http://mintload.com/upload/upload-single.php
The last two digits of time() function are shown and iframe is refreshed every 3sec.
But, the moment one clicks "Upload" button, the file starts uploading, but iframe no more refreshes & freezes. In IE7 it works fine. Why not in Firefox Latest Ver: 3.6 ?

code for iframe:

header("refresh:1; $_SERVER[PHP_SELF]");
echo substr(time(),-2,2);

My point is, just as in IE, my iframe shouldnt freeze refreshing even if a file is being uploaded. Any code/functions?

Please help. Thank you.

2
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by akshayinbox
0

why would it?

You were not including the "url=" part. INSTEAD of the header() function, you can try:

echo '<script>location.href="'.$_SERVER['PHP_SELF'].'?cb=(new Date()).valueOf()";</script>';
exit();
0

Well, I need to display percent done.

So, new code is:
(help me fix this)

header("Cache-Control: no-cache \n");
header("Pragma: no-cache \n");
header("Expires: 0 \n");
header("Refresh:3; $_SERVER[PHP_SELF]?sid=$sessionid");
//echo '<script>location.href="'.$_SERVER.'?sid=(<?php echo $sid; ?>).valueOf()";</script>'; //NOT REQUIRED!
echo $percent_done.'% completed';

0

try:

header("Cache-Control: no-cache \n");
header("Pragma: no-cache \n");
header("Expires: 0 \n");
//header("Refresh:3; $_SERVER[PHP_SELF]?sid=$sessionid");

//not sure if the variable with the id that you are using is $sid OR $sessionid, but be sure to use the correct one below
echo sprintf('<script>setTimeout( function(){location.href="%s?sid=%s&cb=%s"} ,3000);</script>',$_SERVER['PHP_SELF'], $sessionid, time());
echo $percent_done.'% completed';

Edited by hielo: typo

0

@hielo
Woo! It does work! THANKS A LOTTTTTT MAN!

Cheers & my best wishes!

See ya...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.