Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Fedor  
#1 Posted : Monday, November 24, 2003 1:39:00 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,530

Thanks: 4 times
Was thanked: 53 time(s) in 52 post(s)
Image Uploader distributive contains code sample demonstrating how to get uploaded images on server side in ASP using component aspSmartUpload. However it can use another uploaders as well. The code sample below demonstrates how to use Dundas Upload component with Image Uploader. This component is free and you can download it from Dundas web site. Here is an Upload.asp file. All other file are totally the same as in default Image Uploader code sample for ASP.
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("Dundas.Upload.2")
objUpload.SaveToMemory

'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"
	If IsEmpty(objUpload.Form("Description" & I)) Then
		ParameterDescription.Value = ""
	Else
		ParameterDescription.Value = objUpload.Form("Description" & I).Value(0)
	End If
	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 Tuesday, December 15, 2009 8:40:32 AM(UTC)  | Reason: Not specified

Best regards, Fedor Skvortsov
Fedor  
#2 Posted : Monday, November 24, 2003 2:21:00 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,530

Thanks: 4 times
Was thanked: 53 time(s) in 52 post(s)
Here is an Upload.asp file for another free upload component - ABCUpload from WebSupergoo.
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("Dundas.Upload.2")
objUpload.SaveToMemory

'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"
	If IsEmpty(objUpload.Form("Description" & I)) Then
		ParameterDescription.Value = ""
	Else
		ParameterDescription.Value = objUpload.Form("Description" & I).Value(0)
	End If
	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:18:27 PM(UTC)  | Reason: Not specified

Best regards, Fedor Skvortsov
Fedor  
#3 Posted : Monday, November 24, 2003 3:08:00 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,530

Thanks: 4 times
Was thanked: 53 time(s) in 52 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
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.