Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 624
  • Last Modified:

How to set Mouse pointer to hourglass

Hi experts,
When I upload file to server,it take several seconds to process.how can I set the Mouse pointer to Hourglass during this time? or is there a way to disable the Upload button during this time.
Tanks
Suying
0
suying
Asked:
suying
  • 25
  • 14
  • 7
  • +1
1 Solution
 
mgfranzCommented:
Using the Style Sheet property, cursor:wait
0
 
mgfranzCommented:
So I guess you could call the style property when onClick="" is called...
0
 
suyingAuthor Commented:
mqfranz,
thanks for the input. could you tell me how to use Style Sheet property and put it where.
here is the code to upload file
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Attachments</TITLE>
</HEAD>

<BODY>
<BASEFONT FACE="Arial, Helvetica">


<TABLE WIDTH="600" BGCOLOR="#c0c0c0" BORDER=2 CELLPADDING=0 CELLSPACING=3>
 
  <TR>
<TD>
<TABLE WIDTH="100%" BGCOLOR="#c0c0c0" BORDER=0 CELLPADDING=2 CELLSPACING=0>

<TR><TD ALIGN=middle><B><STRONG>Step 1</STRONG>:Click <STRONG>Browse</STRONG> and select your AR file . <STRONG>Step 2</STRONG>: click on "<STRONG>Upload File</STRONG>".Repeat step 1 and 2 to upload more files. <STRONG>Step 3</STRONG>: When finished, click on "<STRONG>Done</STRONG>"</B></TD></TR>
<TR><TD><HR></TD></TR>

<TR><TD align=middle >
     <FORM ACTION="uploadfile.asp" METHOD="post" ENCTYPE="multipart/form-data" id=form1 name=form1>
     <INPUT TYPE=file SIZE=60  NAME="Attchment"><BR>
     <INPUT TYPE=submit  style=" FONT-WEIGHT: bold;" VALUE="Upload File" id=SUBMIT1 name=SUBMIT1>
     </FORM>



<INPUT TYPE=submit VALUE="Done" style=" FONT-WEIGHT: bold;"  id=SUBMIT2 name=done>&nbsp;&nbsp;</TD></TR>


<script language=vbscript>
<!--
sub done_onclick()
window.navigate "getautoarnum.asp"
end sub
-->
</script>
</TABLE>
</TD></TR>
</TABLE>

</BASEFONT>
</BODY>
</HTML>

Could you please give me some code.
Thanks
suying
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
mgfranzCommented:
It was just a suggestion... no code...

Where is Sub done getting called?
0
 
suyingAuthor Commented:
from:
<INPUT TYPE=submit VALUE="Done" style=" FONT-WEIGHT: bold;"  id=SUBMIT2 name=done>
suying
0
 
suyingAuthor Commented:
Hi mqfranz,
the <INPUT TYPE=submit VALUE="Done" style=" FONT-WEIGHT: bold;"  id=SUBMIT2 name=done>
is used to close this window and back to another window. the
<INPUT TYPE=submit  style=" FONT-WEIGHT: bold;" VALUE="Upload File" id=SUBMIT1 name=SUBMIT1>
is used to upload file.

any suggestion?
Thanks
Suying
0
 
mgfranzCommented:
Now that I think about it, using the Style property will not work... since style properties are set on page load, the only way to change the style would be to reload the page, sorry.
0
 
davlun20080Commented:
Actually, since you are using vbscript, assume this is an ie based application.  If so, you can change styles dynamically.

Here is a change to your vbscript code, try it and see if it works, orplace this where it will be called during the upload.  

<script language=vbscript>
<!--
sub done_onclick()
window.navigate "getautoarnum.asp"
document.body.style.cursor = "wait"
end sub
-->
</script>


Then you will need to add something somewhere that processes when the upload is complete to turn it off.

davlun
0
 
suyingAuthor Commented:
Davlun,
Thanks for the input. the Done button is for close current(upload file window)window and go back to getautonum.asp. so I can't put the document.body.style.cursor="wait". maybe I can add  sub Upload_Onclick and add document.body.style.cursor="wait" in this sub,Could you please tell me how:>>Then you will need to add something somewhere that processes when the upload is complete to turn it off.(because I don't know how. thanks)
Suying
0
 
davlun20080Commented:
Some of what you ask i can not do because i do not know how your site is put together as a whole.

As for the first part of your response, you already have the pieces in your response.  Try creating a sub Upload_Onclick and placing the line, document.body.style.cursor = "wait" in the sub.  Try it ans see if it works.

If so, give me more info about how your server handles the upload so you know when the upload is complete.  Once you know when the upload is complete, we can write something to change the cursor back.

davlun
0
 
suyingAuthor Commented:
Hi davlun,
thanks.I've added the code as you told me:
Sub Upload_Onclick()
document.body.style.cursor = "wait"
end sub
it doesn't work because I didn't see any change as before.
here is the code in uploadform.htm
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Attachments</TITLE>
</HEAD>

<BODY>
<BASEFONT FACE="Arial, Helvetica">


<TABLE WIDTH="600" BGCOLOR="#c0c0c0" BORDER=2 CELLPADDING=0 CELLSPACING=3>
 
  <TR>
<TD>
<TABLE WIDTH="100%" BGCOLOR="#c0c0c0" BORDER=0 CELLPADDING=2 CELLSPACING=0>

<TR><TD ALIGN=middle><B><STRONG>Step 1</STRONG>:Click <STRONG>Browse</STRONG> and select your AR file . <STRONG>Step 2</STRONG>: click on "<STRONG>Upload File</STRONG>".Repeat step 1 and 2 to upload more files. <STRONG>Step 3</STRONG>: When finished, click on "<STRONG>Done</STRONG>"</B></TD></TR>
<TR><TD><HR></TD></TR>

<TR><TD align=middle >
      <FORM ACTION="uploadfile.asp" METHOD="post" ENCTYPE="multipart/form-data" id=form1 name=form1>
      <INPUT TYPE=file SIZE=60  NAME="Attchment"><BR>
      <INPUT TYPE=submit  style=" FONT-WEIGHT: bold;" VALUE="Upload File" id=SUBMIT1 name=SUBMIT1>
      </FORM>



<INPUT TYPE=submit VALUE="Done" style=" FONT-WEIGHT: bold;"  id=SUBMIT2 name=done>&nbsp;&nbsp;</TD></TR>


<script language=vbscript>
<!--
sub done_onclick()
window.navigate "getautoarnum.asp"
end sub
-->
</script>
</TABLE>
</TD></TR>
</TABLE>

</BASEFONT>
</BODY>
</HTML>
and here is the code in uploadfile.asp
<%@ Language=VBScript %>
<%Option Explicit%>
<!-- #include file="upload.asp" -->
<!-- #Include file="adovbs.inc" -->
<%
session("firstattach")=true

' Create the FileUploader
Dim Uploader, File
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()
' Check if any files were uploaded
dim constring
dim objcon
set objcon=server.CreateObject("ADODB.Connection")
constring="Provider=MSDAORA.1;Password=esoapp;User ID=esoapp;Data Source=rmdodtest;Persist Security Info=True"
objcon.ConnectionString=constring
 objcon.cursorLocation=adUseClient
objcon.open
dim RS,strattach
strattach="select * from ""ARAttachments"" "

If Uploader.Files.Count = 0 Then
      Response.Write "File(s) not uploaded."
Else
      ' Loop through the uploaded files
      For Each File In Uploader.Files.Items
                              
                  ' Open the table you are saving the file to
       Set RS = Server.CreateObject("ADODB.Recordset")
         RS.Open strattach,objcon,adOpenDynamic ,adLockOptimistic
             RS.AddNew ' create a new record
             RS("AttachID")=1
             RS("ARNumber")=Session("arnumber")
             RS("FileName")    = File.FileName
             RS("FileSize")=File.FileSize
             RS("ContentType")=File.ContentType
                  ' Save the file to the database
             File.SaveToDatabase RS("Attachment")
            
                  ' Commit the changes and close
             RS.Update
             RS.Close
            
            
      Next
End If
Response.Redirect "uploadform.htm"
%>
the code for upload.asp(which is a include file in uploadfile.asp)is:
<%

Class FileUploader
      Public  Files
      Private mcolFormElem

      Private Sub Class_Initialize()
            Set Files = Server.CreateObject("Scripting.Dictionary")
            Set mcolFormElem = Server.CreateObject("Scripting.Dictionary")
      End Sub
      
      Private Sub Class_Terminate()
            If IsObject(Files) Then
                  Files.RemoveAll()
                  Set Files = Nothing
            End If
            If IsObject(mcolFormElem) Then
                  mcolFormElem.RemoveAll()
                  Set mcolFormElem = Nothing
            End If
      End Sub

      Public Property Get Form(sIndex)
            Form = ""
            If mcolFormElem.Exists(LCase(sIndex)) Then Form = mcolFormElem.Item(LCase(sIndex))
      End Property

      Public Default Sub Upload()
            Dim biData, sInputName
            Dim nPosBegin, nPosEnd, nPos, vDataBounds, nDataBoundPos
            Dim nPosFile, nPosBound
            biData = Request.BinaryRead(Request.TotalBytes)
            nPosBegin = 1
            nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
            
            If (nPosEnd-nPosBegin) <= 0 Then Exit Sub
             
            vDataBounds = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
            nDataBoundPos = InstrB(1, biData, vDataBounds)
            
            Do Until nDataBoundPos = InstrB(biData, vDataBounds & CByteString("--"))
                  
                  nPos = InstrB(nDataBoundPos, biData, CByteString("Content-Disposition"))
                  nPos = InstrB(nPos, biData, CByteString("name="))
                  nPosBegin = nPos + 6
                  nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(34)))
                  sInputName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                  nPosFile = InstrB(nDataBoundPos, biData, CByteString("filename="))
                  nPosBound = InstrB(nPosEnd, biData, vDataBounds)
                  
                  If nPosFile <> 0 And  nPosFile < nPosBound Then
                        Dim oUploadFile, sFileName
                        Set oUploadFile = New UploadedFile
                        
                        nPosBegin = nPosFile + 10
                        nPosEnd =  InstrB(nPosBegin, biData, CByteString(Chr(34)))
                        sFileName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                        oUploadFile.FileName = Right(sFileName, Len(sFileName)-InStrRev(sFileName, "\"))
                        nPos = InstrB(nPosEnd, biData, CByteString("Content-Type:"))
                        nPosBegin = nPos + 14
                        nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
                        
                        oUploadFile.ContentType = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                        
                        nPosBegin = nPosEnd+4
                        nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
                        oUploadFile.FileData = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
                        
                        If oUploadFile.FileSize > 0 Then Files.Add LCase(sInputName), oUploadFile
                  Else
                        nPos = InstrB(nPos, biData, CByteString(Chr(13)))
                        nPosBegin = nPos + 4
                        nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
                        If Not mcolFormElem.Exists(LCase(sInputName)) Then mcolFormElem.Add LCase(sInputName), CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                  End If

                  nDataBoundPos = InstrB(nDataBoundPos + LenB(vDataBounds), biData, vDataBounds)
            Loop
      End Sub

      'String to byte string conversion
      Private Function CByteString(sString)
            Dim nIndex
            For nIndex = 1 to Len(sString)
               CByteString = CByteString & ChrB(AscB(Mid(sString,nIndex,1)))
            Next
      End Function

      'Byte string to string conversion
      Private Function CWideString(bsString)
            Dim nIndex
            CWideString =""
            For nIndex = 1 to LenB(bsString)
               CWideString = CWideString & Chr(AscB(MidB(bsString,nIndex,1)))
            Next
      End Function
End Class

Class UploadedFile
      Public ContentType
      Public FileName
      Public FileData
      
      Public Property Get FileSize()
            FileSize = LenB(FileData)
      End Property

      Public Sub SaveToDisk(sPath)
            Dim oFS, oFile
            Dim nIndex
      
            If sPath = "" Or FileName = "" Then Exit Sub
            If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"
      
            Set oFS = Server.CreateObject("Scripting.FileSystemObject")
            If Not oFS.FolderExists(sPath) Then Exit Sub
            
            Set oFile = oFS.CreateTextFile(sPath & FileName, True)
            
            For nIndex = 1 to LenB(FileData)
                oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))
            Next

            oFile.Close
      End Sub
      
      Public Sub SaveToDatabase(ByRef oField)
            If LenB(FileData) = 0 Then Exit Sub
            
            If IsObject(oField) Then
                  oField.AppendChunk FileData
            End If
      End Sub

End Class
%>
( I will increase the points since you spend lot of time on my question)
Thanks
Suying
0
 
suyingAuthor Commented:
Hi davlun,
thanks.I've added the code as you told me:
Sub Upload_Onclick()
document.body.style.cursor = "wait"
end sub
it doesn't work because I didn't see any change as before.
here is the code in uploadform.htm
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Attachments</TITLE>
</HEAD>

<BODY>
<BASEFONT FACE="Arial, Helvetica">


<TABLE WIDTH="600" BGCOLOR="#c0c0c0" BORDER=2 CELLPADDING=0 CELLSPACING=3>
 
  <TR>
<TD>
<TABLE WIDTH="100%" BGCOLOR="#c0c0c0" BORDER=0 CELLPADDING=2 CELLSPACING=0>

<TR><TD ALIGN=middle><B><STRONG>Step 1</STRONG>:Click <STRONG>Browse</STRONG> and select your AR file . <STRONG>Step 2</STRONG>: click on "<STRONG>Upload File</STRONG>".Repeat step 1 and 2 to upload more files. <STRONG>Step 3</STRONG>: When finished, click on "<STRONG>Done</STRONG>"</B></TD></TR>
<TR><TD><HR></TD></TR>

<TR><TD align=middle >
      <FORM ACTION="uploadfile.asp" METHOD="post" ENCTYPE="multipart/form-data" id=form1 name=form1>
      <INPUT TYPE=file SIZE=60  NAME="Attchment"><BR>
      <INPUT TYPE=submit  style=" FONT-WEIGHT: bold;" VALUE="Upload File" id=SUBMIT1 name=SUBMIT1>
      </FORM>



<INPUT TYPE=submit VALUE="Done" style=" FONT-WEIGHT: bold;"  id=SUBMIT2 name=done>&nbsp;&nbsp;</TD></TR>


<script language=vbscript>
<!--
sub done_onclick()
window.navigate "getautoarnum.asp"
end sub
-->
</script>
</TABLE>
</TD></TR>
</TABLE>

</BASEFONT>
</BODY>
</HTML>
and here is the code in uploadfile.asp
<%@ Language=VBScript %>
<%Option Explicit%>
<!-- #include file="upload.asp" -->
<!-- #Include file="adovbs.inc" -->
<%
session("firstattach")=true

' Create the FileUploader
Dim Uploader, File
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()
' Check if any files were uploaded
dim constring
dim objcon
set objcon=server.CreateObject("ADODB.Connection")
constring="Provider=MSDAORA.1;Password=esoapp;User ID=esoapp;Data Source=rmdodtest;Persist Security Info=True"
objcon.ConnectionString=constring
 objcon.cursorLocation=adUseClient
objcon.open
dim RS,strattach
strattach="select * from ""ARAttachments"" "

If Uploader.Files.Count = 0 Then
      Response.Write "File(s) not uploaded."
Else
      ' Loop through the uploaded files
      For Each File In Uploader.Files.Items
                              
                  ' Open the table you are saving the file to
       Set RS = Server.CreateObject("ADODB.Recordset")
         RS.Open strattach,objcon,adOpenDynamic ,adLockOptimistic
             RS.AddNew ' create a new record
             RS("AttachID")=1
             RS("ARNumber")=Session("arnumber")
             RS("FileName")    = File.FileName
             RS("FileSize")=File.FileSize
             RS("ContentType")=File.ContentType
                  ' Save the file to the database
             File.SaveToDatabase RS("Attachment")
            
                  ' Commit the changes and close
             RS.Update
             RS.Close
            
            
      Next
End If
Response.Redirect "uploadform.htm"
%>
the code for upload.asp(which is a include file in uploadfile.asp)is:
<%

Class FileUploader
      Public  Files
      Private mcolFormElem

      Private Sub Class_Initialize()
            Set Files = Server.CreateObject("Scripting.Dictionary")
            Set mcolFormElem = Server.CreateObject("Scripting.Dictionary")
      End Sub
      
      Private Sub Class_Terminate()
            If IsObject(Files) Then
                  Files.RemoveAll()
                  Set Files = Nothing
            End If
            If IsObject(mcolFormElem) Then
                  mcolFormElem.RemoveAll()
                  Set mcolFormElem = Nothing
            End If
      End Sub

      Public Property Get Form(sIndex)
            Form = ""
            If mcolFormElem.Exists(LCase(sIndex)) Then Form = mcolFormElem.Item(LCase(sIndex))
      End Property

      Public Default Sub Upload()
            Dim biData, sInputName
            Dim nPosBegin, nPosEnd, nPos, vDataBounds, nDataBoundPos
            Dim nPosFile, nPosBound
            biData = Request.BinaryRead(Request.TotalBytes)
            nPosBegin = 1
            nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
            
            If (nPosEnd-nPosBegin) <= 0 Then Exit Sub
             
            vDataBounds = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
            nDataBoundPos = InstrB(1, biData, vDataBounds)
            
            Do Until nDataBoundPos = InstrB(biData, vDataBounds & CByteString("--"))
                  
                  nPos = InstrB(nDataBoundPos, biData, CByteString("Content-Disposition"))
                  nPos = InstrB(nPos, biData, CByteString("name="))
                  nPosBegin = nPos + 6
                  nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(34)))
                  sInputName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                  nPosFile = InstrB(nDataBoundPos, biData, CByteString("filename="))
                  nPosBound = InstrB(nPosEnd, biData, vDataBounds)
                  
                  If nPosFile <> 0 And  nPosFile < nPosBound Then
                        Dim oUploadFile, sFileName
                        Set oUploadFile = New UploadedFile
                        
                        nPosBegin = nPosFile + 10
                        nPosEnd =  InstrB(nPosBegin, biData, CByteString(Chr(34)))
                        sFileName = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                        oUploadFile.FileName = Right(sFileName, Len(sFileName)-InStrRev(sFileName, "\"))
                        nPos = InstrB(nPosEnd, biData, CByteString("Content-Type:"))
                        nPosBegin = nPos + 14
                        nPosEnd = InstrB(nPosBegin, biData, CByteString(Chr(13)))
                        
                        oUploadFile.ContentType = CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                        
                        nPosBegin = nPosEnd+4
                        nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
                        oUploadFile.FileData = MidB(biData, nPosBegin, nPosEnd-nPosBegin)
                        
                        If oUploadFile.FileSize > 0 Then Files.Add LCase(sInputName), oUploadFile
                  Else
                        nPos = InstrB(nPos, biData, CByteString(Chr(13)))
                        nPosBegin = nPos + 4
                        nPosEnd = InstrB(nPosBegin, biData, vDataBounds) - 2
                        If Not mcolFormElem.Exists(LCase(sInputName)) Then mcolFormElem.Add LCase(sInputName), CWideString(MidB(biData, nPosBegin, nPosEnd-nPosBegin))
                  End If

                  nDataBoundPos = InstrB(nDataBoundPos + LenB(vDataBounds), biData, vDataBounds)
            Loop
      End Sub

      'String to byte string conversion
      Private Function CByteString(sString)
            Dim nIndex
            For nIndex = 1 to Len(sString)
               CByteString = CByteString & ChrB(AscB(Mid(sString,nIndex,1)))
            Next
      End Function

      'Byte string to string conversion
      Private Function CWideString(bsString)
            Dim nIndex
            CWideString =""
            For nIndex = 1 to LenB(bsString)
               CWideString = CWideString & Chr(AscB(MidB(bsString,nIndex,1)))
            Next
      End Function
End Class

Class UploadedFile
      Public ContentType
      Public FileName
      Public FileData
      
      Public Property Get FileSize()
            FileSize = LenB(FileData)
      End Property

      Public Sub SaveToDisk(sPath)
            Dim oFS, oFile
            Dim nIndex
      
            If sPath = "" Or FileName = "" Then Exit Sub
            If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"
      
            Set oFS = Server.CreateObject("Scripting.FileSystemObject")
            If Not oFS.FolderExists(sPath) Then Exit Sub
            
            Set oFile = oFS.CreateTextFile(sPath & FileName, True)
            
            For nIndex = 1 to LenB(FileData)
                oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))
            Next

            oFile.Close
      End Sub
      
      Public Sub SaveToDatabase(ByRef oField)
            If LenB(FileData) = 0 Then Exit Sub
            
            If IsObject(oField) Then
                  oField.AppendChunk FileData
            End If
      End Sub

End Class
%>
( I will increase the points since you spend lot of time on my question)
Thanks
Suying
0
 
davlun20080Commented:
hmmm, so you want the cursor to go to an hourglass after you click the submit button in uploadform.htm?
0
 
suyingAuthor Commented:
Davlun,
Yes.that's what I'm want.is that possible? if yes,could you please tell me how?

thanks
Suying
0
 
davlun20080Commented:
Add the following code to the top of uploadform.asp, insert it right before you create the file uploader.

response.write "<html><body><head><title>Some Title</title></head><body style=""cursor: wait"">Please Wait . . .</body></html>

If this works, it will write out a blank page while the stuff is processing and the cursor should be an hourglass as well, not sure on this one but we will see soon enough

davlun
0
 
suyingAuthor Commented:
Hi Davlun,
when I add the code you gave me, I got the follow output:
Please Wait...
Response object error 'ASP 0156: 80004005'
Header Error
AROnline/uploadfile.asp line 50
The HTTP line already written to the client browser,Any HTTP header modification must be made before writing page content.
(because I have a response.redirect "uploadform.htm" in uploadfile.asp used to let people upload more file)

the mouse pointer is hourglass.

Suying
0
 
davlun20080Commented:
Ok, did not think that would matter....

So change the first line i gave you to:
response.write "<html><body><head><title>Some Title</title></head><body style=""cursor: wait"">Please
Wait . . "

and where you have the redirect, add this instead of the redirect:
response.write "<script language=""javascript"">window.location.replace(""uploadform.htm"")</script></body></html>"

basically I am using javascript to redirect back when the asp page is finished.  I am using the replace method to keep the processing page from being added to the history.

if this doesn't work I am out of easy solutions,
davlun

0
 
suyingAuthor Commented:
Hi Davlun,
if I change the code to what you gave me,it didn't show Please Wait... and the mouse pointer didn't change to hourglass.
Suying
0
 
EyalCommented:
all the code have to be in the same page to make it work.
try this:

response.buffer=true
response.write "<html><body><head><title>Some Title</title></head><body style=""cursor: wait"">Please
Wait . . .</body></html>
response.Flash

do upload work...

response.redirect "OtherPage.asp"


0
 
suyingAuthor Commented:
Thanks Eyal,I will check the code on Monday.
Suying
0
 
suyingAuthor Commented:
Hi Eyal,
when I add the code in uploadfile.asp(if I'm right)I got the follow page:
when I add the code you gave me, I got the follow output:
Please Wait...
Response object error 'ASP 0156: 80004005'
Header Error

AROnline/uploadfile.asp line 50
The HTTP line already written to the client browser,Any HTTP header modification must be made before
writing page content.
(because I have a response.redirect "uploadform.htm" in uploadfile.asp used to let people upload more
file)

the mouse pointer is hourglass.
Thanks
Suying
0
 
EyalCommented:
put the
response.buffer=true
on the top of the ASP page
0
 
suyingAuthor Commented:
Hi Eyal,
the first two line in this page are including file:
<!-- #include file="upload.asp" -->
<!-- #Include file="adovbs.inc" -->
 then I put the response.buffer=true on the third line.
do you mean I need put the response.buffer=true in front of including file?
Thanks
Suying
0
 
EyalCommented:
yes.

this setting will tell the asp to hold all the output data in buffer until u do response.flash or the page ends its proccess
0
 
suyingAuthor Commented:
Hi Eyal,
I still got the same error.
here is code for uploadfile.asp<% response.buffer=true %>
<!-- #include file="upload.asp" -->
<!-- #Include file="adovbs.inc" -->
<%
response.write "<html><head><title>Some Title</title></head><body style=""cursor: wait"">Please Wait . . .</body></html>"
Response.Flush
session("firstattach")=true

' Create the FileUploader
Dim Uploader, File
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()
' Check if any files were uploaded
dim constring
dim objcon
set objcon=server.CreateObject("ADODB.Connection")
constring="Provider=MSDAORA.1;Password=esoapp;User ID=esoapp;Data Source=rmdodtest;Persist Security
Info=True"
objcon.ConnectionString=constring
objcon.cursorLocation=adUseClient
objcon.open
dim RS,strattach
strattach="select * from ""ARAttachments"" "

If Uploader.Files.Count = 0 Then
     Response.Write "File(s) not uploaded."
Else
     ' Loop through the uploaded files
     For Each File In Uploader.Files.Items
                         
               ' Open the table you are saving the file to
      Set RS = Server.CreateObject("ADODB.Recordset")
        RS.Open strattach,objcon,adOpenDynamic ,adLockOptimistic
           RS.AddNew ' create a new record
           RS("AttachID")=1
           RS("ARNumber")=Session("arnumber")
           RS("FileName")    = File.FileName
           RS("FileSize")=File.FileSize
           RS("ContentType")=File.ContentType
               ' Save the file to the database
           File.SaveToDatabase RS("Attachment")
         
               ' Commit the changes and close
           RS.Update
           RS.Close
         
         
     Next
End If
Response.Redirect "uploadform.htm"
%>
I think the error is caused by Response.Redirect "uploadform.htm"

any suggestion?
Thanks
Suying
0
 
davlun20080Commented:
The problem I think is on the redirect, which is why I split the code in the second try, to try and keep the system from thinking it is receiving two sets of headers, one for the start of the html page and one for the redirect.

Also, the asp error you had from Eyal's code maybe due to a syntax error, I think.  Change the response.flash to response.flush and give it a try.

davlun
0
 
EyalCommented:
davlun20080 is right its indeed Flush :) (10x 4 the correction)

if the redirect still doesn't work put this lines

<form name="FormRedirect" action="uploadform.htm" method="post"><input type="hidden" name="tmp"></form>
<script LANGUAGE="javascript">
   document.FormRedirect.submit();
<%Response.End%>
0
 
suyingAuthor Commented:
Hi Davlun,
If I change the code as you told me, the Please Wait... didn't show and the monse pointer didn't change to hourglass( the code Eyal give is Flush not flash,sorry for typo error)here is the code in uploadfile.asp
here is code for uploadfile.asp

<% response.buffer=true %>
<!-- #include file="upload.asp" -->
<!-- #Include file="adovbs.inc" -->
<%
response.write "<html><head><title>Some Title</title></head><body style=""cursor: wait"">Please Wait..."

Response.Flush
session("firstattach")=true

' Create the FileUploader
Dim Uploader, File
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()
' Check if any files were uploaded
dim constring
dim objcon
set objcon=server.CreateObject("ADODB.Connection")
constring="Provider=MSDAORA.1;Password=esoapp;User ID=esoapp;Data Source=rmdodtest;Persist Security

Info=True"
objcon.ConnectionString=constring
objcon.cursorLocation=adUseClient
objcon.open
dim RS,strattach
strattach="select * from ""ARAttachments"" "

If Uploader.Files.Count = 0 Then
    Response.Write "File(s) not uploaded."
Else
    ' Loop through the uploaded files
    For Each File In Uploader.Files.Items
                       
              ' Open the table you are saving the file to
     Set RS = Server.CreateObject("ADODB.Recordset")
       RS.Open strattach,objcon,adOpenDynamic ,adLockOptimistic
          RS.AddNew ' create a new record
          RS("AttachID")=1
          RS("ARNumber")=Session("arnumber")
          RS("FileName")    = File.FileName
          RS("FileSize")=File.FileSize
          RS("ContentType")=File.ContentType
              ' Save the file to the database
          File.SaveToDatabase RS("Attachment")
         
              ' Commit the changes and close
          RS.Update
          RS.Close
         
         
    Next
End If
response.write "<script language=""javascript"">window.location.replace(""uploadform.htm"")</script></body></html>"
%>

Thanks
Suying
0
 
suyingAuthor Commented:
Hi Eyal
Where to put your code,do I still need response.redirect"uploadform.htm

Thanks
Suying
0
 
davlun20080Commented:
OK, have done a little research and what I was surmising is true. You cannot use response.redirect after you have already sent the headers to the page.  Here is an excerpt from some literature explaining the response.redirect:

This method works by sending a 302 Object Moved status header to the browser.

All HTTP headers must be sent before any content is sent to the browser. If you disable buffering of script output and attempt to use this method after you have already sent content to the browser, FoxWeb will return an error message.

Any form of solution will need to involve processing in the client and a work around for sure.  Will try to work something out.

davlun
0
 
suyingAuthor Commented:
Hi Davlun,
Thank you so much.I'm new to asp so I don't know too much. if you can help me out( I don't know if there is any solution for this), I will deeply appreciate.

Thanks
Suying
0
 
davlun20080Commented:
Not sure if this will work, hopefully it will.  Otherwise, you will need to use frames basically, submit in a hidden frame and then update the main page when you are finished.

This may or may not be compatible with the rest of your system...

davlun

*********  begin code here  ***********

<%@ Language=VBScript %>
<% Response.buffer = true %>
<%Option Explicit%>
<!-- #include file="upload.asp" -->
<!-- #Include file="adovbs.inc" -->
<%
session("firstattach")=true

response.write "<html><head><title>Some Title</title></head><body style=""cursor: wait"">Please wait..."

' Create the FileUploader
Dim Uploader, File
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()
' Check if any files were uploaded
dim constring
dim objcon
set objcon=server.CreateObject("ADODB.Connection")
constring="Provider=MSDAORA.1;Password=esoapp;User ID=esoapp;Data Source=rmdodtest;Persist Security
Info=True"
objcon.ConnectionString=constring
objcon.cursorLocation=adUseClient
objcon.open
dim RS,strattach
strattach="select * from ""ARAttachments"" "

If Uploader.Files.Count = 0 Then
     Response.Write "File(s) not uploaded."
Else
     ' Loop through the uploaded files
     For Each File In Uploader.Files.Items
                         
               ' Open the table you are saving the file to
      Set RS = Server.CreateObject("ADODB.Recordset")
        RS.Open strattach,objcon,adOpenDynamic ,adLockOptimistic
           RS.AddNew ' create a new record
           RS("AttachID")=1
           RS("ARNumber")=Session("arnumber")
           RS("FileName")    = File.FileName
           RS("FileSize")=File.FileSize
           RS("ContentType")=File.ContentType
               ' Save the file to the database
           File.SaveToDatabase RS("Attachment")
         
               ' Commit the changes and close
           RS.Update
           RS.Close
         
         
     Next
End If

Response.write "<script language=""javascript"">window.setTimeout(""window.location.replace(""uploadform.htm"", 500)</script></body></html>"
Response.end

%>

0
 
suyingAuthor Commented:
Hi davlun,
could you tell me where I should put the )in :
Response.write "<script language=""javascript"">window.setTimeout(""window.location.replace(""uploadform.htm"",
500)</script></body></html>"
Response.end
because I got the error said expert ")" with the line:
<html><head><title>Some Title</title></head><body style="cursor: wait">Please Wait . . .<script language="javascript">window.SetTimeOut("window.location.replace("editattach.htm"),500)</script></body></html>
I try to put .<script language="javascript">window.SetTimeOut("window.location.replace("editattach.htm"),500)</script></body></html>
or .<script language="javascript">window.SetTimeOut("window.location.replace("editattach.htm",500))</script></body></html>
got the same error

Thanks
suying
0
 
EyalCommented:
repolace the response.redirect with my code
0
 
suyingAuthor Commented:
Hi Eyal,
when I replace the redirect with the code:

<form name="FormRedirect" action="uploadform.htm" method="post"><input type="hidden" name="tmp"></form>
<script LANGUAGE="javascript">
<!--
  document.FormRedirect.submit();
  -->

</script>
  <%Response.End%>
I got this error:
HTTP Error 405
405 Method Not Allowed

The method specified in the Request Line is not allowed for the resource identified by the request. Please ensure that you have the proper MIME type set up for the resource you are requesting.

Please contact the server's administrator if this problem persists.
(in your code, what the input type=hidden do?)
Thanks
Suying
0
 
davlun20080Commented:
Suying,
Use my code in it's entirety, exactly as it is written for your file uploadfile.asp.  Make sure you use the double quotes "" as that is the escape sequence in asp for outputing a single ".

Please post the entire error msg from my code if possible.  It looks like your response was munged a little bit.

davlun

NOTE FOR Eyal:
Before we propose more solutions that involve a redirect, please see my note above regarding how the redirect process works, it may help you help suying.  Unless you can find an exception somewhere, any form of redirect will not be allowed if you have already sent headers to the browser.

0
 
suyingAuthor Commented:
Hi davlun,
here is the code you gave me:
<% Response.Buffer =true %>

<!-- #include file="upload.asp" -->
<!-- #Include file="adovbs.inc" -->

<%
response.write "<html><head><title>Some Title</title></head><body style=""cursor: wait"">Please Wait . . ."
.....
upload file code goes here
response.write "<script language=""javascript"">window.SetTimeOut(""window.location.replace(""editattach.htm""),500)</script></body></html>"
%>
when I run it, I get the page with Please Wait... and an error dialog box(small one) with Title Error and the content is:
A Runtime Error has Occurred. Do you wish to debug?
Line: 0
Error:Expected ')'

Yes    No
when I click the Yes button, it gave me the follow line :
<html><head><title>Some Title</title></head><body style="cursor: wait">Please Wait . . .<script language="javascript">window.SetTimeOut("window.location.replace("editattach.htm"),500)</script></body></html>

Suying

0
 
davlun20080Commented:
Ooops, even that code in a simple html file doesn't work, not sure why...exactly.

Try this:
   Replace the first part of the html written out with this:
      "<html><head><title>Some Title</title><script language=""JavaScript"">function replaceWin(){ window.location.replace('editattach.htm'); }</script></head><body style=""cursor: wait"" onload=""replaceWin()"">Please Wait . . ."

   and replace the bottom part with this:
      "</body></html>"

Maybe, just maybe this will work....

0
 
suyingAuthor Commented:
Hi davlun,
if I change to the code you gave me, the mouse pointer did not change to hourglass.

Thanks
Suying
0
 
davlun20080Commented:
Hmmm, then i am out of ideas.  Did the page relocate at the end of the processing?
0
 
suyingAuthor Commented:
Hi davlun,
seems not.(Did the page relocate at the end of the processing? )
thank you so much.I will close this Q at the end of this week and give you the points(not too many,sorry)since you spent lot of time.

Thanks again
Suying
0
 
davlun20080Commented:
sorry not able to help further.  wish i could of.
davlun
0
 
EyalCommented:
davlun20080:
because he did this in the code

response.write "<html><head><title>Some Title</title></head><body style=""cursor: wait"">Please Wait
. . .</body></html>"

I gave him a javascript that will do the trick(It works for me :)

suying:
the hidden input box is to support netscape problem (not allow empty forms)

do your browser have friendly errors marked?
I need more details on the error.
0
 
suyingAuthor Commented:
Hi Eyal,
here is the error:
HTTP Error 405
405 Method Not Allowed

The method specified in the Request Line is not allowed for the resource identified by the request. Please ensure that you have the proper MIME type set up for the resource you are requesting.

Please contact the server's administrator if this problem persists.
is that the <form> tag must be inside of the <body> tag.
if I use the code:(which you gave me)

response.buffer=true
response.write "<html><body><head><title>Some Title</title></head><body style=""cursor: wait"">Please

Wait . . .</body></html>
response.Flash

do upload work...

<form name="FormRedirect" action="uploadform.htm" method="post"><input type="hidden" name="tmp"></form>
<script LANGUAGE="javascript">
<!--
  document.FormRedirect.submit();
-->
</script>
<%Response.End%>
I got the above error.no more output tell my which line cause the error.

any suggestion?
Thanks
Suying

0
 
EyalCommented:
<%Response.buffer=true
response.write "<html><body><head><title>Some Title</title></head><body style=""cursor: wait"">Please Wait . . .
response.Flush ' this will throw the message to the client browser

'do upload work...

'this will do the redirect method%>
<form name="FormRedirect" action="uploadform.htm" method="post"><input type="hidden" name="tmp"></form>
<script LANGUAGE="javascript">
<!--
 document.FormRedirect.submit();
-->
</script>
</body></html>
<%Response.Flush
Response.End%>
0
 
suyingAuthor Commented:
Hi Eyal,
got the same error.
Thanks
Suying
0
 
davlun20080Commented:
Unless I am mistaken, Response.Write has the same effect as putting some html outside of the asp delimiters and then calling the Response.Flush method.  Response.write actually flushes the stream up to that point... I think.

I am very interested to see if Eyal is able to get this working since my research indicates any form of redirect is not possible after already sending headers to the page.

good luck all
0
 
suyingAuthor Commented:
thanks for the effort. I will close this Q, if you have better idea please add comment here.

Thanks again.
0
 
suyingAuthor Commented:
Thanks davlun,if you get better idea,please add a comment to that Q.
0
 
davlun20080Commented:
sorry could not be of more service.  davlun
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 25
  • 14
  • 7
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now