mjxnjx
October 14th, 2002, 03:57 PM
Hello Gurus!
The following upload script works fine for small file uploads. But if the upload takes too long (for bigger files, for example), the UploadWindow errors out "Page Cannot be Displayed" after a few moments. I'm assuming the window is waiting for a response back, not getting it, and is erroring out as a result.
Here's an overview of what's supposed to be happening:
1) User is given a form by which to select a file to upload.
2) User clicks on the submit button, thereby opening a new window that will handle the file upload.
3) The main window then updates with a new message and is free for use to do other things while the upload is happening.
4) When the upload is complete, the Uploadwindow closes automatically by the window.close() command sent by the server side script.
Here's what happens with a bigger file:
4) The Upload is interrupted part way through by a message "Page Cannot be Displayed". The Upload is also interrupted so the file is only partially transferred. The server never has the opportunity to send window.close() so the Uploadwindow is left open with this ugly message of "Page Cannot be Displayed".
The browser seems to be really impatient on getting a response during a bigger upload. How can I make it happy?
<HTML>
<HEAD>
<TITLE>Uploading Single File</TITLE>
<SCRIPT LANGUAGE='JavaScript'>
<!-- Begin
function checkFile()
{
tmp=document.form1.cmuds.value;
if (tmp.length<1)
{
alert('Please enter a file to upload before continuing')
document.form1.cmuds.focus();
}
else
{
upwin = window.open('','UploadWindow','dependant=yes,height=50,width=300,menubar=no,status=no,titlebar=no,toolbar=no,alwayslowered=yes');
upwin.document.writeln("<HTML><HEAD>");
var filepath;
re = / /gi;
filepath = tmp.replace(re,'%20');
upwin.document.writeln("</HEAD><BODY><CENTER>Uploading...",tmp,"</BODY></HTML>");
upwin.document.close();
document.form1.submit();
document.close();
document.write("<HTML><HEAD><TITLE>Uploading Single File</TITLE>");
document.write("</HEAD><BODY><p><center>");
document.write("File is Uploading in another window. This window is free for use while that one is uploading. </body></html>");
document.close();
}
}
// End -->
</script>
</HEAD>
<BODY>
<p><center>
<form target='UploadWindow' action='http://yadaplace/yadayada.pl' method='POST' focus='cmuds' name=form1 enctype='multipart/form-data'>
Please Select the File you wish to Upload to the Server.<BR><BR>
<input type='file' name='cmuds' size=50>
<input type=submit name='uploadit' value='Upload It' OnClick='checkFile()'>
</form>
</body>
</html>
The following upload script works fine for small file uploads. But if the upload takes too long (for bigger files, for example), the UploadWindow errors out "Page Cannot be Displayed" after a few moments. I'm assuming the window is waiting for a response back, not getting it, and is erroring out as a result.
Here's an overview of what's supposed to be happening:
1) User is given a form by which to select a file to upload.
2) User clicks on the submit button, thereby opening a new window that will handle the file upload.
3) The main window then updates with a new message and is free for use to do other things while the upload is happening.
4) When the upload is complete, the Uploadwindow closes automatically by the window.close() command sent by the server side script.
Here's what happens with a bigger file:
4) The Upload is interrupted part way through by a message "Page Cannot be Displayed". The Upload is also interrupted so the file is only partially transferred. The server never has the opportunity to send window.close() so the Uploadwindow is left open with this ugly message of "Page Cannot be Displayed".
The browser seems to be really impatient on getting a response during a bigger upload. How can I make it happy?
<HTML>
<HEAD>
<TITLE>Uploading Single File</TITLE>
<SCRIPT LANGUAGE='JavaScript'>
<!-- Begin
function checkFile()
{
tmp=document.form1.cmuds.value;
if (tmp.length<1)
{
alert('Please enter a file to upload before continuing')
document.form1.cmuds.focus();
}
else
{
upwin = window.open('','UploadWindow','dependant=yes,height=50,width=300,menubar=no,status=no,titlebar=no,toolbar=no,alwayslowered=yes');
upwin.document.writeln("<HTML><HEAD>");
var filepath;
re = / /gi;
filepath = tmp.replace(re,'%20');
upwin.document.writeln("</HEAD><BODY><CENTER>Uploading...",tmp,"</BODY></HTML>");
upwin.document.close();
document.form1.submit();
document.close();
document.write("<HTML><HEAD><TITLE>Uploading Single File</TITLE>");
document.write("</HEAD><BODY><p><center>");
document.write("File is Uploading in another window. This window is free for use while that one is uploading. </body></html>");
document.close();
}
}
// End -->
</script>
</HEAD>
<BODY>
<p><center>
<form target='UploadWindow' action='http://yadaplace/yadayada.pl' method='POST' focus='cmuds' name=form1 enctype='multipart/form-data'>
Please Select the File you wish to Upload to the Server.<BR><BR>
<input type='file' name='cmuds' size=50>
<input type=submit name='uploadit' value='Upload It' OnClick='checkFile()'>
</form>
</body>
</html>