Make Revenue With Your Own Banner Management System - The ASP to add the banner
(Page 4 of 11 )
If you were paying attention over the last page or two, you would remember that our "Add a Banner" form posts our form data to addbanner2.asp. We'll create the addbanner2.asp page with the following code snippets (again, don't worry if you don't understand it, it will all make sense at the end of the article):
<%@ Language="VBScript" %>
<!-- METADATA Type="TypeLib" File="c:\program files\common files\system\ado\msado15.dll" -->If you've had even the smallest amount of exposure to ASP, you should be familiar with the <%@ Language=”VBScript” %> directive. This directive is optional, but should be included. It simply lets the ASP engine know that our page will contain VBScript code and not Jscript.
The next tag may look unfamiliar. This is a special type of tag called a server-side include (or SSI for short). This tag tells the ASP engine to extract all constants and variables (knows as a type library) from the msado15.dll file (located in the c:\program files\common files\system\ado) directory on our web server. Msado15.dll (MSADO15 - Microsoft ActiveX Data Objects version 1.5) contains all of the constants that we will be using when we declare our database objects, such as cursor types, lock types, etc.
set objConn = Server.CreateObject("ADODB.Connection")
set objRS = Server.CreateObject("ADODB.Recordset")
set objUpload = Server.CreateObject("Persits.Upload.1")
strBanner_Path = "c:\inetpub\wwwroot\banners"
objUpload.OverwriteFiles = True
objUpload.Save strBanner_PathThe three "set ..." lines instantiate the database and upload objects that our script uses to handle our data. The first two set commands declare our database connection and recordset objects, which will be used to connect to and update our database respectively. The next line, set objUpload = Server.CreateObject("Persits.Upload.1") makes reference to our ActiveX object which will handle the uploading of our banner image. The ActiveX component is called Persits ASP Upload and can be downloaded from
http://www.persits.com. Once you have downloaded the self-extracting executable, it's just a simple matter of running the install program and restarting your web server.
Moving on, the strBanner_Path variable will hold the location of the directory in which we want our banners to reside once they have been uploaded. This should be a sub-directory of the directory holding your ASP scripts on the server (for example, if my scripts were located in c:\myscripts, I would use something like c:\myscripts\images for the images directory. Make sure the directory for your images exists before you run the script!). Change this variable if you need to. After this, we just set our Persits upload component to overwrite image files if they already exist, and set the save parameter to the strBanner_Path variable.
Next: The ASP to add the banner (contd) >>
More ASP Articles
More By Mitchell Harper