Rank: Advanced Member
Groups: Member, Administration, Moderator Joined: 7/28/2003(UTC) Posts: 1,660
Thanks: 5 times Was thanked: 76 time(s) in 74 post(s)
|
Here is an Upload.asp file for another upload component - AspUpload from Persists. Code:<%
' Aurigma Image Uploader Sample Script
' Copyright(c) Aurigma Inc. 2002-2003
' WWW: http://www.aurigma.com
'Modify this block, according to your needs.
Dim strGalleryPath, strConnectionString, MyConnection
'This variable specifies a relative path to the folder, where image gallery is located.
'Don't forget to add slash at the end of the path
strGalleryPath = "Gallery/"
'Connection string to database with image descriptions
strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath("DB/Demo.mdb") & ";"
'Create Connection
Set MyConnection = Server.CreateObject("ADODB.Connection")
MyConnection.Open strConnectionString
'We delete all files and descriptions for old files
Dim objFileSystem, objFolder, objSubFolder, objFile
Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject")
'Delete source images
Set objFolder = objFileSystem.GetFolder(Server.MapPath(strGalleryPath))
For Each objFile In objFolder.Files
objFileSystem.DeleteFile objFile.Path, True
Next
'Delete thumbnails
Set objFolder = objFileSystem.GetFolder(Server.MapPath(strGalleryPath) & "\Thumbnails")
For Each objFile In objFolder.Files
objFileSystem.DeleteFile objFile.Path, True
Next
'Delete descriptions from database
MyConnection.Execute "DELETE FROM [File]"
'Process upload
Dim objUpload
Dim intFileCount, I
Dim strAuthor
'We create aspSmartUpload object for uploading images
Set objUpload = Server.CreateObject("Persits.Upload")
objUpload.Save
'We create command for adding items in database
Dim MyCommand
Set MyCommand = Server.CreateObject("ADODB.Command")
MyCommand.ActiveConnection = MyConnection
MyCommand.CommandText = "INSERT INTO [File](Name, Width, Height, Author, Description) " & _
"VALUES (?, ?, ?, ?, ?)"
'Add parameters to collection
Dim ParameterName, ParameterWidth, ParameterHeight, ParameterAuthor, ParameterDescription
Set ParameterName = MyCommand.CreateParameter("Name", 200, 1, 50)
MyCommand.Parameters.Append ParameterName
Set ParameterWidth = MyCommand.CreateParameter("Width", 3, 1)
MyCommand.Parameters.Append ParameterWidth
Set ParameterHeight = MyCommand.CreateParameter("Height", 3, 1)
MyCommand.Parameters.Append ParameterHeight
Set ParameterAuthor = MyCommand.CreateParameter("Author", 200, 1, 50)
MyCommand.Parameters.Append ParameterAuthor
Set ParameterDescription = MyCommand.CreateParameter("Description", 200, 1, 255)
MyCommand.Parameters.Append ParameterDescription
'Set Author parameter value
ParameterAuthor.Value = objUpload.Form("Author").Value
'Total amount of uploaded files
intFileCount = objUpload.Form("ImageCount").Value
'We run over uploaded images and load it
For I=1 To intFileCount
'Fetch source images and save it to disk
Set objFile = objUpload.Files("Image" & I)
objFile.SaveAs (Server.MapPath("Gallery/" & I & ".jpg"))
'Fetch thumbnails and save it to disk
Set objFile = objUpload.Files("Thumbnail" & I)
objFile.SaveAs (Server.MapPath("Gallery/Thumbnails/" & I & ".jpg"))
'Save description in database
ParameterName.Value = I & ".jpg"
ParameterDescription.Value = objUpload.Form("Description" & I).Value
ParameterWidth.Value = objUpload.Form("Width" & I).Value
ParameterHeight.Value = objUpload.Form("Height" & I).Value
MyCommand.Execute
Next
'Clean up
MyConnection.Close
%>
======================================================== 02/14/2008, Fedor This topic is out of date. The actual samples are included in distribution since version 2.x. ========================================================Edited by user Wednesday, October 29, 2008 2:11:15 PM(UTC)
| Reason: Not specified |
Best regards, Fedor Skvortsov
|