【发布时间】:2012-03-29 11:01:33
【问题描述】:
嘿……有点急…… 我使用临时文件夹来存储预览图像,当我尝试保存它们时 System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+ erreo is reported... If FileUpload1.HasFile Then 暗淡路径为 String = Server.MapPath("./TempImages/") 将 oFileInfo 调暗为新的 FileInfo(FileUpload1.PostedFile.FileName)
Dim fileName As String = oFileInfo.Name
Dim fullFileName As String = path + "\\" + fileName
Dim imagePath As String = "TempImages/" + fileName
If Not Directory.Exists(path) Then
Directory.CreateDirectory(path)
End If
FileUpload1.PostedFile.SaveAs(fullFileName)
Image1.ImageUrl = imagePath
这就是我正在做和保存的事情
如果 (FileUpload1.HasFile) 那么 暗淡 strextension As String = System.IO.Path.GetExtension(FileUpload1.FileName) If (strextension.ToUpper() = ".JPG") 那么
Dim imagetoberezised As System.Drawing.Image = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream)
Dim imageheight As Integer = imagetoberezised.Height
Dim imagewidth As Integer = imagetoberezised.Width
Dim maxheight As Integer = 120
Dim maxwidth As Integer = 80
imageheight = (imagewidth * maxheight) / imageheight
imagewidth = maxheight
If imageheight > maxheight Then
imageheight = (imagewidth * maxheight) / imageheight
imagewidth = maxheight
End If
Dim bitmap As New Bitmap(imagetoberezised, imagewidth, imageheight)
Dim stream As System.IO.MemoryStream = New MemoryStream()
bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg)
stream.Position = 0
Dim img As Byte() = New Byte(stream.Length) {}
stream.Read(img, 0, img.Length)
Dim conn5 As New SqlConnection
conn5 = New SqlConnection
conn5.ConnectionString = "Server=aa-pc;Database=abcc;Uid=sa;Pwd=sa@123;"
Try
conn5.Open()
Dim sql As String = "update abcset abc_IMAGE = @eimg where PART_NO=" & Val(Part_List.SelectedValue)
Dim cmd5 As SqlCommand = New SqlCommand(sql, conn5)
Dim uploadimage As New SqlParameter("@eimg", SqlDbType.Image, img.Length)
uploadimage.Value = img
cmd5.Parameters.Add(uploadimage)
Dim id As Integer = Convert.ToInt32(cmd5.ExecuteScalar())
Catch
MsgBox("error")
Finally
conn5.Close()
End Try
End If
End If
当我们在本地而不是在服务器上运行它时,它运行良好..
【问题讨论】:
标签: asp.net