You will need to ask your web hosting company to create a folder on your server where you can upload files to it. You will also need to find out if your web hosting company supports ASP SmartUpload. I hope that this sample code will help.
Take a look at a form that you could create for this application:
<FORM NAME="frmPictures" ACTION="AddPictures.asp" METHOD="post"
onSubmit="return InputIsValid()" ENCTYPE="multipart/form-data">
<TABLE width=400 align=center valign="top" cellpadding=2 cellspacing=0 border=0 bgcolor=#cccccc>
<TR>
<TD align=right><STRONG><font face=arial size=-1>Name </font></STRONG></TD>
<TD><INPUT NAME="txtName" SIZE=30 > </TD>
</TR>
<TR> <TD align="right"><STRONG><font face=arial size=-1>Image</font></STRONG></TD>
'You will browse for an image file on your computer that you would like to upload to your web site:
<TD width="70%"><INPUT TYPE="file" name="file" size="35"></TD></TR>
<tr>
<td align=right> </td>
<td align=middle>
<INPUT
Type=submit
Name=subSubmit Value="Submit"> <INPUT id=reset1 name=reset1 style="WIDTH: 74px; HEIGHT: 24px" type=reset value="Clear form">
</td></tr></TABLE></FORM>
Here's the sample code for the second page that will add and upload the picture. You will also add a name to the name field in the database.
<%
' Variables
' *********
Dim mySmartUpload
Dim file
Dim Name
'Declare constants for a recordset that allows adding records
'You can also just include the file ADOVBS.INC to get these constants
Const adLockOptimistic = 3
Const adOpenDynamic = 2
dim connectionString, databaseName, path
dim sqlString
' Object creation
' ***************
Set mySmartUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
' Upload
' ******
mySmartUpload.Upload
SpecialsName = mySmartUpload.Form("txtName")
' Connect to the DB
' *****************
' Open a recordset
' ****************
'Start sql string with Join
'Create the recordset
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sqlString, connectionString, adOpenDynamic, adLockOptimistic
' Select each file
' ****************
For each file In mySmartUpload.Files
' Only if the file exist
' **********************
If not file.IsMissing Then
' Add the current file in a DB field
' **********************************
fic="Upload/" &file.FileName&""
file.SaveAs(fic)
Rs.AddNew
Rs("ImageName") = file.FileName
Rs("Name") = Name
Rs.Update
End If
Next
' Destruction
' ***********
rs.Close
Set rs = Nothing
You said that you would like to know how to display the picture on a web page. I'll give you some code sample for the web page that will display the picture. You can figure out the code for everything else.
You should have something like this if you want to display a picture from a database:
<a href="Picture.asp?qryID=<%=rs("PictureID")%>"><img src=../Upload/<%= rs("ImageName") %> width="100" height="100" border="0" alt=<%= rs("Name")%>></a>