updatepic.aspx

来自「asp做的新闻系统」· ASPX 代码 · 共 50 行

ASPX
50
字号
<%@ import namespace="System" %>  
<%@ import namespace="System.Drawing" %>  
<%@ import namespace="System.Drawing.Imaging" %>  
<%@ import namespace="System.IO" %> 

<script runat="server">  
   Sub sendFile()  
    dim g as System.Drawing.Image = System.Drawing.Image.FromFile(server.mappath (request("src")))  
    dim thisFormat=g.rawformat  
    dim imgOutput as New Bitmap(g, cint(request("width")), cint(request("height")))  

    if thisformat.equals(system.drawing.imaging.imageformat.Gif) then  
      response.contenttype="image/gif"  
    else  
      response.contenttype="image/jpeg"  
    end if  

    imgOutput.save(response.outputstream, thisformat) 
    g.dispose()  
    imgOutput.dispose()  
end sub  

Sub sendError()  
    dim imgOutput as New bitmap(120, 120, pixelformat.format24bpprgb)  
    dim g as graphics = graphics.fromimage(imgOutput)  
    g.clear(color.yellow) 
    g.drawString("错误!", New font("黑体",14,fontstyle.bold),systembrushes.windowtext, New pointF(2,2))  
    response.contenttype="image/gif"  
    imgOutput.save(response.outputstream, imageformat.gif)  
    g.dispose()  
    imgOutput.dispose()  
  end sub  
</script>  

<%  
response.clear 

if request("src")="" or request("height")="" or request("width")="" then  
    call sendError()  
else  
    if file.exists(server.mappath(request("src"))) then  
      call sendFile()  
    else  
      call sendError()  
    end if  
end if  

response.end  
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?