Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
Dim productId As Integer = 0
Dim userId As Integer = 0
userId = Convert.ToInt32(Session(Common.SESSION_USERID).ToString())
Dim strImage1 As String = String.Empty
Dim FileImage1 As String = String.Empty
Dim strParth1 As String = String.Empty
Dim strRemoveString1 As String = String.Empty
If (flImage1.HasFile) Then
Dim strPath As String = Server.MapPath("Common/ProductImages/")
flImage1.SaveAs(strPath + flImage1.FileName)
strParth1 = strPath + flImage1.FileName
FileImage1 = flImage1.FileName
strImage1 = "Common/ProductImages/" + flImage1.FileName
Dim big As String = "~Big"
Dim strm As Stream = flImage1.PostedFile.InputStream
Dim targetFile = strParth1
GenerateThumbnails(3.0, strm, targetFile, big)
Else
End If
If Request.QueryString("Id") IsNot Nothing Then
productId = InsertUpdateProduct(Convert.ToInt32(Request.QueryString("Id")), userId, txtName.Text, editorDesc.Content, txtPrice.Text, strImage1, txtShippingPrice.Text)
If productId > 0 Then
lblMsg.Text = "updated successfuly...."
lblMsg.ForeColor = System.Drawing.Color.Green
End If
Else
Dim strProductCount As Integer
Dim strPlan As String = String.Empty
strProductCount = Session(Common.SESSION_ProductCount)
strPlan = Session(Common.SESSION_PlanTitle)
If (Convert.ToInt32(strProductCount) < 30 And strPlan = "Gold Member") Then
productId = InsertUpdateProduct(0, userId, txtName.Text, editorDesc.Content, txtPrice.Text, strImage1, strImage2, strImage3, txtShippingPrice.Text)
If productId > 0 Then
lblMsg.Text = "inserted successfuly...."
lblMsg.ForeColor = System.Drawing.Color.Green
End If
Else
End If
End If
End Sub
Private Sub GenerateThumbnails(ByVal scaleFactor As Double, ByVal sourcePath As Stream, ByVal targetPath As String, ByVal name As String)
Using image = System.Drawing.Image.FromStream(sourcePath)
Dim newWidth = CInt(Math.Truncate(image.Width * scaleFactor))
Dim newHeight = CInt(Math.Truncate(image.Height * scaleFactor))
Dim thumbnailImg = New Bitmap(newWidth, newHeight)
Dim thumbGraph = Graphics.FromImage(thumbnailImg)
thumbGraph.CompositingQuality = CompositingQuality.HighQuality
thumbGraph.SmoothingMode = SmoothingMode.HighQuality
thumbGraph.InterpolationMode = InterpolationMode.HighQualityBicubic
Dim imageRectangle = New Rectangle(0, 0, newWidth, newHeight)
thumbGraph.DrawImage(image, imageRectangle)
Dim withoutExtension As String = targetPath
Dim strImage As String = String.Empty
Dim strArr() As String
strArr = withoutExtension.Split(".")
strImage = strArr(0)
targetPath = strImage + ".jpg"
Dim targetPath1 As String = targetPath.Replace(Path.GetFileNameWithoutExtension(targetPath), Path.GetFileNameWithoutExtension(targetPath) & name)
thumbnailImg.Save(targetPath1, image.RawFormat)
thumbnailImg.Dispose()
End Using
End Sub
Above this code are properly working on local or IIS but in Server this code is not working
It's a generic error occurred in gdi+
Please resolve this problem....
It's urgent.