Makeyour own banner managementsystem with ASP (continued)
The ASP to add the banner
Ifyou were paying attentionover the last page or two,you would remember thatour "Add a Banner" formposts our form data to addbanner2.asp.We'll create the addbanner2.asppage with the followingcode snippets (again, don'tworry if you don't understandit, it will all make senseat the end of the article):
<%@ Language="VBScript" %>
<!-- METADATA Type="TypeLib"File="c:\program files\commonfiles\system\ado\msado15.dll"-->
If you've had even the smallestamount of exposure to ASP,you should be familiar withthe <%@ Language=”VBScript”%> directive. This directiveis optional, but shouldbe included. It simply letsthe ASP engine know thatour page will contain VBScriptcode and not Jscript.
The next tag may look unfamiliar.This is a special type oftag called a server-sideinclude (or SSI for short).This tag tells the ASP engineto extract all constantsand variables (knows asa type library) from themsado15.dll file (locatedin the c:\program files\commonfiles\system\ado) directoryon our web server. Msado15.dll(MSADO15 - Microsoft ActiveXData Objects version 1.5)contains all of the constantsthat we will be using whenwe declare our databaseobjects, such as cursortypes, 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"
The three "set ..." linesinstantiate the databaseand upload objects thatour script uses to handleour data. The first twoset commands declare ourdatabase connection andrecordset objects, whichwill be used to connectto and update our databaserespectively. The next line,set objUpload = Server.CreateObject("Persits.Upload.1")makes reference to our ActiveXobject which will handlethe uploading of our bannerimage. The ActiveX componentis called Persits ASP Uploadand can be downloaded fromhttp://www.persits.com/.Once you have downloadedthe self-extracting executable,it's just a simple matterof running the install programand restarting your webserver.
Moving on, the strBanner_Pathvariable will hold the locationof the directory in whichwe want our banners to resideonce they have been uploaded.This should be a sub-directoryof the directory holdingyour ASP scripts on theserver (for example, ifmy scripts were locatedin c:\myscripts, I woulduse something like c:\myscripts\imagesfor the images directory.Make sure the directoryfor your images exists beforeyou run the script!). Changethis variable if you needto. After this, we justset our Persits upload componentto overwrite image filesif they already exist, andset the save parameter tothe strBanner_Path variable.
Top quality daily ASP, PHPand .NET articles, tutorials,news, reviews, interviewsAND FREE EBOOKS! devArticlesis the ultimate online resourcefor the serious web developer.Visit
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More Web Development Articles
More By Developer Shed