Page 1

How to auto close a window? 

Is there any code in asp to auto close a window after a certain amount of time? Thanx in advance Mojito

mojito View Public Profile Send a private message to mojito Find all posts by mojito Add mojito to Your Buddy List   #2    July 23rd, 2004, 04:59 AM 

mojito Registered User

Join Date: Jul 2004 Posts: 15 

Or even better would be if someone could tell me how to redirect to a previous (parent) page after  a certain amount of time.

mojito View Public Profile Send a private message to mojito Find all posts by mojito Add mojito to Your Buddy List   #3    July 23rd, 2004, 05:03 AM 

nasir Registered User

i donot know u can do this in asp or not but u can use javascript like this <SCRIPT> setTimeout("self.close()", 5000 ) // after 5 seconds </SCRIPT> u can use this within asp script too bye

nasir View Public Profile Send a private message to nasir Send email to nasir Visit nasir's homepage!

Join Date: Oct 2003 Location: Islamabad Posts: 20 

Find all posts by nasir Add nasir to Your Buddy List   #4    July 23rd, 2004, 05:08 AM 

mojito Registered User

Join Date: Jul 2004 Posts: 15 

Ok...thanx a lot...that worked... but what I really want is that the child page redirects to the (previous)parent page after a certain  amount of time.

mojito View Public Profile Send a private message to mojito Find all posts by mojito Add mojito to Your Buddy List   #5    July 23rd, 2004, 05:53 AM 

nasir Registered User

ok try to use this one <script language="JavaScript"> <!­­ function refreshParent() { window.opener.location.href = window.opener.location.href; if (window.opener.progressWindow) { window.opener.progressWindow.close() } window.close(); } //­­> </script>

nasir View Public Profile Send a private message to nasir Send email to nasir Visit nasir's homepage!

Join Date: Oct 2003 Location: Islamabad Posts: 20 

Find all posts by nasir Add nasir to Your Buddy List   #6    July 23rd, 2004, 06:19 AM 

nasir Registered User

Join Date: Oct 2003 Location: Islamabad Posts: 20 

or just try this one <script language="JavaScript"> <!­­ history.go(­1); //­­> </script>

How to upload images from local to server hardisk? NEED HELP~ 

hello.. everyone, anyone here know how to create a asp pages for uploading images from local  disk to server disk by using method upload.asp?? have any relevant information for me to refer.  Thanks a lot for helping.

violet View Public Profile Send a private message to violet Send email to violet Find all posts by violet Add violet to Your Buddy List   #2    July 15th, 2004, 12:42 AM 

Doug G 


Search these forums and you'll find many upload topics with examples. __________________ ====== Doug G ====== 

Doug G View Public Profile Send a private message to Doug G Find all posts by Doug G Add Doug G to Your Buddy List

Join Date: Sep 2003 Posts: 1,962 

#3    July 15th, 2004, 03:40 AM 

Bullschmidt Guru

Join Date: May 2003 Location: USA Posts: 434 

Perhaps this may hopefully give you some ideas: Classic ASP Design Tips ­ File Upload­fileupload.asp The Anonymous Internet user needs Change permission on the folder that a file is going to be  uploaded to and actually Full Access might be better if you are later going to use the  FileSystemObject to delete a file. And whatever file uploading solution you use, on the page in question you will no longer be able  to refer to regular form fields with Request.Form("MyField"). Instead there will be some kind of  proprietary way to refer to the fields. And here is a pure ASP (i.e. no components) resource for letting the user upload a file which is  something that was unfortunately not built into ASP: ASP File Upload Using VBScript by John R. Lewis ­ 7/10/2000 __________________ J. Paul Schmidt, Freelance ASP Web Developer Classic ASP Design Tips, ASP Web Database Demo, ASP Bar Chart Tool... 

Bullschmidt View Public Profile Send a private message to Bullschmidt Send email to Bullschmidt Visit Bullschmidt's homepage! Find all posts by Bullschmidt Add Bullschmidt to Your Buddy List   #4    July 15th, 2004, 04:33 AM 

RobUK Registered User

Pure ASP can do this. #Include this file in the page the form is posted to:­  Code:


Join Date: Jul 2004 Location: UK Posts: 101 

'*************************************** ' File: Upload.asp ' Author: Jacob "Beezle" Gilley ' Email: ' Date: 12/07/2000 ' Comments: The code for the Upload, CByteString, ' CWideString subroutines was originally ' written by Philippe Collignon...or so ' he claims. Also, I am not responsible ' for any ill effects this script may ' cause and provide this script "AS IS". ' Enjoy! '**************************************** 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("ContentDisposition"))

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, nPosEndnPosBegin)) 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, nPosEndnPosBegin) 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 %> Here is an example form to use with this:­  Code:

<HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> <TITLE></TITLE> </HEAD> <BODY> <FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="uploadexmple.asp"> <TABLE BORDER=0> <tr><td><b>Enter your fullname:</b><br><INPUT TYPE=TEXT SIZE=40 NAME="FULLNAME"></td></tr>

<tr><td><b>Select a file to upload:</b><br><INPUT TYPE=FILE SIZE=50 NAME="FILE1"></td></tr> <tr><td><b>Save To:</b>&nbsp;&nbsp; Disk&nbsp;<INPUT TYPE=RADIO NAME="saveto" value="disk" checked>&nbsp;&nbsp; Database&nbsp;<INPUT TYPE=RADIO NAME="saveto" value="database"> </td></tr> <tr><td align="center"><INPUT TYPE=SUBMIT VALUE="Upload!"></td></tr> </TABLE> </FORM> </BODY> </HTML> And here is the example ASP file to process the form:­  Code:

<%@ Language=VBScript %> <%Option Explicit%> <!-- #include file="upload.asp" --> <% 'NOTE - YOU MUST HAVE VBSCRIPT v5.0 INSTALLED ON YOUR WEB SERVER ' FOR THIS LIBRARY TO FUNCTION CORRECTLY. YOU CAN OBTAIN IT ' FREE FROM MICROSOFT WHEN YOU INSTALL INTERNET EXPLORER 5.0 ' OR LATER. ' Create the FileUploader Dim Uploader, File Set Uploader = New FileUploader ' This starts the upload process Uploader.Upload() '****************************************** ' Use [FileUploader object].Form to access ' additional form variables submitted with ' the file upload(s). (used below) '****************************************** Response.Write "<b>Thank you for your upload " & Uploader.Form("fullname") & "</b><br>" ' Check if any files were uploaded 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 ' Check where the user wants to save the file If Uploader.Form("saveto") = "disk" Then ' Save the file File.SaveToDisk "E:\UploadedFiles\" ElseIf Uploader.Form("saveto") = "database" Then ' Open the table you are saving the file to Set RS = Server.CreateObject("ADODB.Recordset") RS.Open "MyUploadTable", "CONNECT STRING OR ADO.Connection", 2, 2

RS.AddNew ' create a new record RS("filename") = File.FileName RS("filesize") = File.FileSize RS("contenttype") = File.ContentType ' Save the file to the database File.SaveToDatabase RS("filedata") ' Commit the changes and close RS.Update RS.Close End If ' Output the file details to the browser Response.Write "File Uploaded: " & File.FileName & "<br>" Response.Write "Size: " & File.FileSize & " bytes<br>" Response.Write "Type: " & File.ContentType & "<br><br>" Next End If %>

Hope the above helps.

RobUK View Public Profile Send a private message to RobUK Visit RobUK's homepage! Find all posts by RobUK Add RobUK to Your Buddy List   #5    July 23rd, 2004, 12:40 AM 


Registered User

Join Date: Jun 2004 Posts: 39 

Thanks alot provide me such a great information abt uploading images. but i have try it.. but it still  cant upload the images from local disk and store at the server disk.Below is my script, i hope  anyone here can correct for me. thansk. logostore.asp <% Dim objConn, objRSDealer Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open strConnect

Set objRSDealer = Server.CreateObject("ADODB.Recordset") objRSDealer.Open "Select Distinct DealerProfile.DealerID, DealerProfile.BusinessName from  DealerProfile order by BusinessName", objConn, adOpenForwardOnly, adLockReadOnly,  adCmdText %>  <FORM METHOD="POST" ENCTYPE="multipart/form­data" ACTION="UploadLogo1.asp"> Select Dealer: <Select name="dealer"> <%  while NOT objRSDealer.EOF %> <OPTION value=<%=objRSDealer("DealerID")%> > <%= objRSDealer("BusinessName") %> <% objRSDealer.MoveNext Wend %> </Select> <br></br> <br></br> <INPUT TYPE=FILE SIZE=60 NAME="FILE1"><BR> <br></br> <INPUT TYPE=SUBMIT VALUE="Upload!"> <INPUT Type= reset Value= "Cancel"> </form> <% objRSDealer.Close objConn.Close Set objRSDealer = Nothing Set objConn = Nothing %> ==================================================  ================================================== ===== UploadLogo1.asp <%@ Language=VBScript %> <!­­ #include file="upload.asp" ­­> <% ' Create the FileUploader Dim Uploader, File Set Uploader = New FileUploader ' This starts the upload process Uploader.Upload() Dim temp , Dealer, image1 temp = 1 Dealer= Uploader.Form("dealer") image1 =Uploader.Form("Image1") ' Check if any files were uploaded 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

' Save the file File.SaveToDisk Server.Mappath("\cstudio\") 'cstudio is my ftp server side name. File.SaveToDatabase("DealerProfile") if temp=1 then  image1=File.FileName End If  ' Output the file details to the browser Response.Write "File Uploaded: " & File.FileName & "<br>" Response.Write "Size: " & File.FileSize & " bytes<br>" Response.Write "Type: " & File.ContentType & "<br><br>" Next End If Session("Dealer")=Dealer Session("Image1")=image1 Response.write " I'm here " if(1) then  Response.Redirect "Savelogo.asp" else  Response.Write " Unable to Save in to Database" end if %> ==================================================  ====================================== Savelogo.asp <% Dim dealerid,Image1,objConn, objCommand1, ASPErr ,temp dealerid= Session("Dealer") image1 =Session("Image1") Set objCommand1 = Server.CreateObject("ADODB.Command") Set ASPErr =Server.GetLastError objCommand1.ActiveConnection = strConnect objCommand1.CommandText = "Update DealerProfile SET BusinessLogo='" & image1 &"' " & _ " Where ((DealerProfile.DealerID)=" &dealerid& ") " objCommand1.CommandType = adCmdText objCommand1.Execute If Err.Number<> 0 then Err.Raise Err.Number,Err.Source ,Err.Description  End If Set objCommand1 = Nothing %> <p><b><font color="#339933" size="4"> The Logo have been uploaded !!! </font></b></p> ==================================================  ======================================== Upload.asp ­­ this files was same as RobUK post above.

the problem i faced now was the images file cant upload and store at the server disk. But i can  check the name of the images(eg:­ picture.gif) this in my database table. What is the problem? i  really have no idea on this. =(

violet View Public Profile Send a private message to violet Send email to violet Find all posts by violet Add violet to Your Buddy List   #6    July 23rd, 2004, 01:41 AM 

freeasphelp Beyond The Impossible

Join Date: Sep 2003 Location: Shawnee Mission, KS, USA Posts: 377 

Environment.asp: Code:

<%@ Language = "VBScript" %> <% Option Explicit Dim objItem For Each objItem In Request.ServerVariables() Response.Write("<b>" & objItem & "</b> " & Request.ServerVariables(objItem) & "<br />") Next %> Please paste the result of this file, so we can debug further. __________________ John Shepard Beyond The Impossible ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ About Me and Free Stuff  • •

About Me    Free Downloads 

My Projects and Sites  • • •

The FreeSiteSpace Group    Free Web Dev Help    FreeASPHelp 

Last edited by freeasphelp : July 23rd, 2004 at 01:46 AM. 

freeasphelp View Public Profile Send a private message to freeasphelp Visit freeasphelp's homepage! Find all posts by freeasphelp Add freeasphelp to Your Buddy List   #7    July 23rd, 2004, 03:34 AM 

violet Registered User

Join Date: Jun 2004 Posts: 39 

hi, freeasphelp! Where should i paste the Environment.asp code that u provided above? which  existing asp file to include it or create other new asp file names"Environment.asp"?

violet View Public Profile Send a private message to violet Send email to violet Find all posts by violet Add violet to Your Buddy List   #8    July 23rd, 2004, 09:00 AM 


Beyond The Impossible

Join Date: Sep 2003 Location: Shawnee Mission, KS, USA Posts: 377 

Create a new file, Environment.asp and paste its output on this thread.


How to auto close a window? nasir Registered User Registered User Send a private message to mojito Send a private message to mojito Send a p...


How to auto close a window? nasir Registered User Registered User Send a private message to mojito Send a private message to mojito Send a p...