home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Practical Internet Web Designer 88
/
PIWD88.iso
/
mac
/
contents
/
developer
/
tutorial_files
/
Pages94-95
/
editalbum2.asp
< prev
next >
Wrap
Text File
|
2003-11-03
|
2KB
|
58 lines
<%@LANGUAGE="VBSCRIPT"%>
<%Option Explicit%>
<%
Dim Upload, uploadArray, fileName, newFileName, fso, imageTitle, imageDesc, conn, strSQL
'Set ASPUpload and grab file
Set Upload = Server.CreateObject("Persits.Upload.1")
Upload.SaveVirtual("/uploads")
'get real filename from end of path
uploadArray = split((Upload.Files(1).Path),"\")
fileName = uploadArray(ubound(uploadArray))
'get form details
imageTitle = Upload.Form("imageTitle")
imageDesc = Upload.Form("imageDesc")
'remove single quotes from title and description
imageTitle = Replace(imageTitle, "'", "''")
imageDesc = Replace(imageDesc, "'", "''")
'make a new filename
newFileName = Now() & fileName
newFileName = Replace(newFileName, " ", "_")
newFileName = Replace(newFileName, "/", "")
newFileName = Replace(newFileName, "\", "")
newFileName = Replace(newFileName, ":", "")
'rename file
Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile Server.MapPath("/uploads/" & fileName), Server.MapPath("/uploads/" & newFileName)
set fso = nothing
set Upload = nothing
'insert details into the database
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=F:\Databases\photoalbum.mdb;" & _
"Jet OLEDB:Database"
strSQL = "INSERT INTO tblImages (imageTitle, imageDesc, imageFilename) VALUES ('" & imageTitle & "','" & imageDesc & "','" & newFileName & "')"
conn.execute(strSQL)
%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Thankyou for uploading your Photograph</title>
<link rel="stylesheet" type="text/css" href="global.css" />
</head>
<body>
<div id="content">
<h1>Upload Successful</h1>
<p>Your file <strong><%=imageTitle%></strong> (<%=fileName%>) was successfully uploaded. Thank you.</p>
<p><img src="/uploads/<%=newFileName%>" alt="<%=imageTitle%>" /></p>
<p><a href="editalbum.asp">Add another photograph</a></p>
</div>
</body>
</html>