Click to See Complete Forum and Search --> : set background image calling upload page


il_betto
06-04-2009, 08:50 AM
Hi to All,
I have a page index.asp in which I make with a button a call to the other page upload.asp

<form method="POST" name="FrontPage_Form2" enctype="multipart/form-data" action="upload.asp">
<input type="file" name="file" size="20">
<input type="image" name="up" id="p" value="upload" onClick="this.form.submit();" src="images/plus2.jpg">
</form>

in the page upload.asp i have this code:

HTML>

<HEAD>
<%@ Language= VBScript %>
<%
'
Server.ScriptTimeout = 100000
Response.Expires=0
Response.Buffer = TRUE
Response.Clear
'
'
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount)
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin
'
'
contentType = UploadRequest.Item("file").Item("ContentType")
filepathname = UploadRequest.Item("file").Item("FileName")
tipo = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"."))
'
If tipo <> "zip" AND tipo <> "pdf" then
Response.Write ("Errore. Non è possibile caricare un file diverso da zip o pdf !!" & tipo)
Response.End
else
If byteCount > 3009000 then
'
Response.Write ("<script>alert('Error. File too big!!');window.history.go(-1);</script>" )
Response.End
else
'
nomefile = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
filename = nomefile
value = UploadRequest.Item("file").Item("Value")
'
Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
pathEnd = Len(Server.mappath(Request.ServerVariables("PATH_INFO")))-14
'
Set MyFile = ScriptObject.CreateTextFile(Server.mappath("archivio_deliver\") &"\"& filename)
For i = 1 to LenB(value)
MyFile.Write chr(AscB(MidB(value,i,1)))
Next
MyFile.Close
End If
End If
%>
</HEAD>

<BODY BACKGROUND="images/sfondo_drago.gif ">
<%
Sub BuildUploadRequest(RequestBin)
PosBeg = 1
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
Dim UploadControl
Set UploadControl = CreateObject("Scripting.Dictionary")
Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
Pos = InstrB(Pos,RequestBin,getByteString("name="))
PosBeg = Pos+6
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
PosBound = InstrB(PosEnd,RequestBin,boundary)
If PosFile<>0 AND (PosFile<PosBound) Then
PosBeg = PosFile + 10
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "FileName", FileName
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
UploadControl.Add "ContentType",ContentType
PosBeg = PosEnd+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
Else
Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
PosBeg = Pos+4
PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
End If
UploadControl.Add "Value" , Value
UploadRequest.Add name, UploadControl
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop
End Sub
Function getByteString(StringStr)
For i = 1 to Len(StringStr)
char = Mid(StringStr,i,1)
getByteString = getByteString & chrB(AscB(char))
Next
End Function

Function getString(StringBin)
getString =""
For intCount = 1 to LenB(StringBin)
getString = getString & chr(AscB(MidB(StringBin,intCount,1)))
Next
End Function
%>
<%
Dim objFSO, objFile, objFolder
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.MapPath("archivio_deliver"))
Response.Write "<P>"
For Each objFile in objFolder.Files
Response.Write Left(objFile.Name, 4) & "<BR>"
Next
Set objFolder = Nothing
Set objFSO = Nothing
%>
</BODY>

</HTML>

My problem is:
if I insert a file of big dimension,
an alert advise me of this, and for me it' s OK !!
But the problem is the background of the page upload.asp, which remains white before one click on the button af alert.
I would like that the background of this page compares always with the image sfondo_drago.gif

I made many tests,
and ONLY if I comment the line "Response.End",
I can reach BODY BACKGROUND....
and I instead I want to exit to the page upload.asp when one click on alert button


Thanks a lot in advance !!!

P.S. I tried to put all the code in the HEAD inside the BODY with no result :mad:

il_betto
06-05-2009, 02:20 AM
I have found a little compromise:

In the page upload.asp I recall an image which guarantees a background not all white ...
....
If tipo <> "zip" AND tipo <> "pdf" then
Response.Write ("<img src='images/sfondo_drago.gif'>")
Response.Write ("<script>alert('Error. It' s not possible to insert file different of Zip or PDF !!');window.history.go(-1);</script>")
Response.End
....

deepu8
06-05-2009, 02:30 AM
you should use comment in your code. Because it is very hard to understand your code.

il_betto
06-05-2009, 03:29 AM
I have solved the problem in this way:

in the page upload.asp I put:
....
If tipo <> "zip" AND tipo <> "pdf" then
Server.Execute("background.asp")
Response.Write ("<script>alert('Error. It' s not possible to insert file different of Zip or PDF !!');window.history.go(-1);</script>")
Response.End
....

And in the page background.asp I wrote:
<HTML>
<BODY BACKGROUND="images/sfondo_drago.gif">
</BODY>
</HTML>

All it' s OK,
the only thing is I would like that the command Server.Execute will execute directly these 4 little lines of code instead of creating a new page background.asp