Hello ,
Intro (don't have to read it ) :
This is my first post over here , I can't call my self a coder of course I just write simple php lines form time to time to do what I need to be done and I'm happy to be in such an amazing community like this
The problem (Please read it ) :
I made a very simple script to remote upload files to my webserver
it consist of 2 files : "index.html" & "download.php"
Here is the code of both of them :
index.html :
<html>
<head>
<title>Remote Upload Page</title>
<script>
function submitonce(theform){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
//screen thru every element in the form, and hunt down "submit" and "reset"
for (i=0;i<theform.length;i++){
var tempobj=theform.elements[i]
if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset")
//disable em
tempobj.disabled=true
}
}
}
</script>
</head>
<body>
<form method=post action="download.php" onSubmit="submitonce(this)">
<p align="center"><b><font face="Tahoma">Enter Download URL :</font></b></p>
<p align="center"> <input type="text" name="Link" size="50" dir="ltr">
<input type="submit" name="submit" value="Upload" dir="ltr"> </p>
</body>
</html>
The java script is just to disable the upload button after clicking on it .
download.php :
<?php
define('BUFSIZ', 4095);
$url = $Link;
$dir = 'files/';
$rfile = fopen($url, 'r');
$lfile = fopen($dir . basename($url), 'w');
while(!feof($rfile))
fwrite($lfile, fread($rfile, BUFSIZ), BUFSIZ);
fclose($rfile);
fclose($lfile);
echo '<p align="center"><b><font face="Tahoma" size="5" color="#339933">File Remote Download Complete !</font></b></p>';
?>
of course no need to explain what I did as you know more than I do !
the problem now :
When I enter a large file URL the page loads for long time and it some times lag my browser , and in the end any way the file don't download if it's big (like more than 100Mb)
so I need to add a progress bar like the one I see on the file uploading websites so that the page don't load for ever
just the progress go from zero to 100 or some thing then echo that the download is complete .
Any info would be helpful and please try to give as much details as possible coz I'm almost a newbie :o
Regards,
Masry