Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question About Uploading a File

Status
Not open for further replies.

byrne1

Programmer
Aug 7, 2001
415
US
I have a page that provides the user a place to upload a file. When they upload the file it has to be immediately processed to add data to a database (this may take a few minutes). What I want to do is forward them to a page that tells them the file is being processed and to please wait but I'm having a difficult time getting this done.

The 'file upload page' remains visible while the file is being processed even though the code to process the file is on a completely seperate page. Unless you notice the IE "flag" waving, you would think that nothing is happening in the background.

Does anyone have an example of how to do what I'm trying to do? Thanks!

 
I had a similar situation about a month ago. What I did was:

When the user clicked upload, I opened a popup window that displayed a html page with an animated gif saying &quot;loading...&quot;. After the file was done uploading, the window closed, and a message was displayed saying &quot;<filename> successfully uploaded&quot;.

To do this, I added an onclick attribute with button1.attributes.add(&quot;onclick&quot;, &quot;poploading();&quot;)
and I also set a hidden input variable called popped = 1.

I then wrote the javascript function to open the popup window:

function poploading(){
var url;
url = &quot;loading.htm&quot;;
loadit = window.open(url, 'loading', 'width=200, height=200, left=150, top=100, status=0, scrollbars=0, user resizeable=0')
}

I added an onunload function to the body tag to close the window after uploading with onunload=&quot;closewindow();&quot;

It's function looked like:

function closeWindow(){
if(popped == 1){
loadit.close();
}
}

...That's how I handled this problem.

hth,
drew10
}
 
That presents the popup window just fine but I can't get it to unload. I've copied some of my code below. Can you see any mistakes that I've made?

<script id=&quot;clientEventHandlersJS&quot; language=&quot;javascript&quot;>
<!--
function popprocessing(){
var url;
url = &quot;processing.htm&quot;;
loadit = window.open(url, 'loading', 'width=400, height=50, left=150, top=100, status=0, scrollbars=0, user resizeable=0')
}

function closeWindow(){
if (popped==1){
loadit.close();
}
}

//-->
</script>

<body id=&quot;body&quot; onunload=&quot;closewindow();&quot;>

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Button1.Attributes.Add(&quot;onclick&quot;, &quot;popprocessing();&quot;)
End Sub

Sub Upload(ByVal Source As Object, ByVal e As EventArgs)
...upload file...
...process file...
request.redirect(&quot;new page.aspx&quot;)
end sub
 
What you need to do is add a hidden input html control that is set to runat=server and call it popped or something. Then in sub upload you need to set popped.value = 1. That way the onunload function will only fire after the popup window has been opened, and not when a user first visits a page.
 
Forget the previous post. I looked over my old source code, but I looked at the wrong version. Here is what you need to do:

1)a variable above the functions called popped

<script language=javascript>
var popped;

function popLoading(){
popped = 1;
var url;
url = &quot;loading.htm&quot;;
loadit = window.open(url, 'loading', 'width=200, height=200, left=150, top=100, status=0, scrollbars=0, user resizeable=0')
}

function closeWindow(){
if(popped == 1){
loadit.close();
}
}

Sorry for the confusion.

-Drew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top