locked
Creating thumbnails after image has uploaded RRS feed

  • Question

  • User-359420042 posted

    I have a list page which displays thumbnails of various books + their details within a GridView, and I have a detail page which displays the full sized version of the same image. I also have an add to database page called addbook.aspx. Here is the code behind for addbook.aspx:

    Imports System.Data.OleDb
    Public Class addBook
        Inherits System.Web.UI.Page
    
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    
        End Sub
    
        Protected Sub btn_submission_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_submission.Click
            Dim myGUID = Guid.NewGuid()
            Dim newFileName As String = myGUID.ToString() & ".jpg"
            Dim fileLocationOnServerHardDisk = Request.MapPath("img") & "/" & newFileName
            fu_picture.SaveAs(fileLocationOnServerHardDisk)
            Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("BookMeetConnString").ConnectionString)
            Dim SqlString As String = "Insert into booklist(Title,Author,PublicationDate,Pages,Publisher,imgurl,AverageRating) Values (@f1,@f2,@f3,@f4,@f5,@f6,@f7)"
            Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
            cmd.CommandType = CommandType.Text
            cmd.Parameters.AddWithValue("@f1", tb_booktitle.Text)
            cmd.Parameters.AddWithValue("@f2", tb_bookauthor.Text)
            cmd.Parameters.AddWithValue("@f3", tb_bookpubyear.Text)
            cmd.Parameters.AddWithValue("@f4", tb_bookpages.Text)
            cmd.Parameters.AddWithValue("@f5", tb_publisher.Text)
            cmd.Parameters.AddWithValue("@f6", "img/" & newFileName)
            cmd.Parameters.AddWithValue("@f7", rbl_Stars.SelectedValue)
            oleDbConn.Open()
            cmd.ExecuteNonQuery()
            Response.Redirect("list.aspx")
    
        End Sub
    End Class

    The code above works absolutely fine, but i would like to modify it so it also produces thumbnail images as well as writing to the database, as well as cater for more than .jpg images.

    How do I acheive this (can it be done in the code behind or do I need to add some sort of package to the solution?)

    EDIT: I am using accdb database, the table is called hotellist as you can see above and the table has both imageurl fields (i.e. full size image urls) and thumburl field (thumbnail image urls - i have already added some thumbnails manually from within access)

    Saturday, March 9, 2013 4:10 PM

Answers

All replies