格式编码有问题
IE可能忽略了
比如一个BMP的文件吧后缀改为GIF
用http就可以看
直接IE
看就出问题了

解决方案 »

  1.   

    编码?我的原来的图片就是JPG的,在生成小图后就什么都变了~
      

  2.   

    你最后输出是用什么编码?
    可能变成了BMP的但是文件后缀依然是JPG
      

  3.   

    不,我的文件做了类型判断的,给代码吧
           Public Function newsadd(ByVal imgfile As System.Web.UI.HtmlControls.HtmlInputFile, ByVal upfile As System.Web.UI.HtmlControls.HtmlInputFile)
                Dim filesavepath As String = "upload"         '文件保存目录
                Dim imgsavepath As String = "img"             '图像保存目录
                Dim bimg, simg As System.Drawing.Image
                Dim callb As System.Drawing.Image.GetThumbnailImageAbort
                Dim simgsavepath As String = "simg"           '缩略图保存目录
                Dim newname As String                         '根据日期生成新文件名
                newname = DateTime.Now.Year.ToString() & DateTime.Now.Month.ToString() & DateTime.Now.Day.ToString() & DateTime.Now.Minute.ToString() & DateTime.Now.Second.ToString()
                Dim fileextension As String                    '文件类型
                Dim filetype As String = ".rar,.zip,.doc,.txt" '文件上传类型定义
                Dim imgtype As String = ".jpg,.bmp,.png"        '图像上传类型定义
                Dim maxfile As Integer = 1024 * 2000           '文件上传大小2M
                Dim maximg As Integer = 1024 * 300             '图像上传大小300K
                Dim msg As String
                '图片开始上传
                Try
                    If imgfile.PostedFile.FileName <> "" Then
                        '图像类型检查
                        fileextension = System.IO.Path.GetExtension(imgfile.PostedFile.FileName).ToLower()
                        If (imgtype.IndexOf(fileextension) = -1) Then
                            msg = "对不起,你要上传的图像不在允许范围内!"
                        Else
                            '图像大小检查
                            If (imgfile.PostedFile.ContentLength > maximg) Then
                                msg = "对不起,上传的图像大小超过300K"
                            Else
                                '保存图像
                                imgfile.PostedFile.SaveAs(Server.MapPath(imgsavepath & "/" & newname & fileextension))
                                '生成缩略图
                                bimg = System.Drawing.Image.FromFile(Server.MapPath(imgsavepath & "/" & newname & fileextension))
                                simg = bimg.GetThumbnailImage(120, 90, Nothing, (New IntPtr).Zero)
                                simg.Save(Server.MapPath(simgsavepath & "/" & newname & fileextension))
                                simg.Dispose()
                                bimg.Dispose()
                            End If
                        End If
                    End If
                Catch
                    msg = "图像上传失败,请重试!"
                End Try
      

  4.   

    感觉你错了,好像simg.Save(Server.MapPath(simgsavepath & "/" & newname & fileextension))这个地方要加编码方式,因为这里的内容是BMP的数据
    应该
    simg.Save(Server.MapPath(simgsavepath & "/" & newname & fileextension),System.Drawing.Imaging.ImageFormat.Jpeg);System.Drawing.Imaging.ImageFormat.Jpeg的内容根据格式不同而变化
      

  5.   

    楼上说的对!System.Drawing.Imaging.ImageFormat.Jpeg
      

  6.   

    fileextension是我获得文件原来的类型,原来是什么类型的,我上传就保留什么类型不转换的,如果采用楼上的,那除JPEG文件类型外,其他的都要转化的哦~再说,就是我选的文件本身是JPEG类型的,在上传后也会出现上述情况的。