aspupload / aspjpeg flere operasjoner. Persits
Hente bilder fra harddisk for så å lagre til database. Hva er koden / objektet for det?----- koden er --------------
<%
' Create an instance of AspUpload object
Set Upload = Server.CreateObject("Persits.Upload")
' Capture uploaded file. Save returns the number of files uploaded
Count = Upload.Save("C:\upload")
If Count = 0 Then
Response.Write "No images selected. <A HREF=""form2.asp"">Try again</A>."
Response.End
Else
' Obtain File object representing uploaded file
Set File = Upload.Files(1)
' Is this a valid image file?
If File.ImageType <> "UNKNOWN" Then
' create instance of AspJpeg object
Set jpeg = Server.CreateObject("Persits.Jpeg")
'--------------------------------------------------------------------
'CREATE THUMBNAIL START
'--------------------------------------------------------------------
' open uploaded file
jpeg.Open( File.Path )
'Resize thumbnail
jpeg.Width = "150"
'Set new height, preserve original width/height ratio on thumbnail.
jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth
'Set the quality.
jpeg.Quality = 40
SavePathThumbNail = "c:\upload\thumbnail_" & File.ExtractFileName
' AspJpeg always generates JPEG thumbnails regardless of original format.
' If the original file was not a JPEG, append .JPG extension.
If UCase(Right(SavePathThumbNail, 3)) <> "JPG" Then
SavePathThumbNail = SavePathThumbNail & ".jpg"
End If
jpeg.Save SavePathThumbNail
'--------------------------------------------------------------------
'CREATE THUMBNAIL END
'--------------------------------------------------------------------
'--------------------------------------------------------------------
'CREATE WATERMARK START
'--------------------------------------------------------------------
' open uploaded file
jpeg.Open( File.Path )
'Resize watermark
jpeg.Width = "300"
'Set new height, preserve original width/height ratio on thumbnail.
jpeg.Height = jpeg.OriginalHeight * jpeg.Width / jpeg.OriginalWidth
'Set the quality.
jpeg.Quality = 60
SavePathWaterMark = "c:\upload\watermark_" & File.ExtractFileName
' AspJpeg always generates JPEG thumbnails regardless of original format.
' If the original file was not a JPEG, append .JPG extension.
If UCase(Right(SavePathWaterMark, 3)) <> "JPG" Then
SavePathWaterMark = SavePathWaterMark & ".jpg"
End If
'Draw text
Jpeg.Canvas.Font.Color = &HFF0000 ' red
Jpeg.Canvas.Font.Family = "Verdana"
Jpeg.Canvas.Font.Size = "20"
Jpeg.Canvas.Font.Bold = True
Jpeg.Canvas.Print Jpeg.Width / 2, Jpeg.Height / 2, "Fotos © 2002"
jpeg.Save SavePathWaterMark
'--------------------------------------------------------------------
'CREATE WATERMARK END
'--------------------------------------------------------------------
' Using ADO, save tree images in the database along with description.
strConnect = "Data Source=" & Server.Mappath("db\aspjpeg.mdb")& ";Provider=Microsoft.Jet.OLEDB.4.0;"
Set rs = Server.CreateObject("adodb.recordset")
rs.Open "images", strConnect, 1, 3
rs.AddNew
' Upload description
rs("description") = Upload.Form("Description")
' Use File.Binary to access binary data of uploaded file.
' Saves the orginal image
rs("orginal_image").Value = File.Binary
' Saves the thumbnail
Set ThumbFile = Upload.OpenFile(file.Path)
rs("thumbnail").Value = ThumbFile.Binary'Hva skal skrives her?
' Saves the watermark image
rs("watermark").Value = File.Binary'Hva skal skrives her?
rs.Update
rs.Close
Set rs = Nothing
Response.Write "Success! The original file, Watermark file and its thumbnail are saved in the database.<P>"
Response.Write "Copies can be found at <B>C:\upload\" & File.ExtractFileName & "</B> , <B>" & SavePathWaterMark & "</B>" & "</B> and <B>" & SavePathThumbNail & "</B><P>"
Response.Write "<a href=view_all_images.asp>view images</a>"
Else
Response.Write "This is not a valid image. <A HREF=""form.asp"">Try again</A>."
Response.End
End If
End If
%>
