欢迎光临
我们一直在努力

ASP+上传文件语法

建站超值云服务器,限时71元/月

这里有一个怎样用asp+上传文件的非常简单例子

<html>

<script language="vb" runat=server>

sub uploadbtn_click(sender as object, e as eventargs)

uploadfile.postedfile.saveas(server.mappath("test.jpg"))

myimage.imageurl = "test.jpg"

myimage.visible = true

end sub

</script>

<body>

<form enctype="multipart/form-data" runat=server>

<h3>

选择上传文件: <input id="uploadfile" type=file runat=server>

<asp:button text="upload me!" onclick="uploadbtn_click" runat=server/>

<hr>

<asp:image id="myimage" visible=false runat=server/>

</form>

</body>

</html>

here is a more complex example, which enables you to upload a file, and then using the system.drawing apis

to resize/crop the image, overlay a custom text message onto the image, and then save it back out to disk

as a .jpg (note that this sample works with *any* browser). ive written this one in c# — but you would

obviously be able to use vb or jscript to do it as well:

<%@ import namespace="system.io" %>

<%@ import namespace="system.drawing" %>

<%@ import namespace="system.drawing.imaging" %>

<html>

<script language="c#" runat=server>

void uploadbtn_click(object sender, eventargs e) {

uploadfile.postedfile.saveas(server.mappath("test.jpg"));

imageeditor.visible = true;

}

void updatebtn_click(object sender, eventargs e) {

system.drawing.image image = system.drawing.image.fromfile(server.mappath("test.jpg"));

system.drawing.image newimage = new bitmap(image.width, image.height, pixelformat.format32bpprgb);

graphics g = graphics.fromimage(newimage);

g.drawimage(image,0,0,image.width,image.height);

font f = new font("lucida sans unicode", int32.parse(fontsize.selecteditem.text));

brush b = new solidbrush(color.red);

g.drawstring(caption.text, f, b, 10, 140);

g.dispose();

system.drawing.image thumbimage = newimage.getthumbnailimage(int32.parse(width.text),int32.parse

(height.text),null,0);

image.dispose();

thumbimage.save(server.mappath("test.jpg"), imageformat.jpeg);

}

</script>

<body>

<form enctype="multipart/form-data" runat=server>

<h3>

select file to upload: <input id="uploadfile" type=file runat=server>

<asp:button text="upload me!" onclick="uploadbtn_click" runat=server/>

<hr>

<asp:panel id="imageeditor" visible=false runat=server>

<img src="test.jpg">

<h3>

image width: <asp:textbox id="width" runat=server/>

image height: <asp:textbox id="height" runat=server/> <br>

text caption: <asp:textbox id="caption" runat=server/>

caption size: <asp:dropdownlist id="fontsize" runat=server>

<asp:listitem>14</asp:listitem>

<asp:listitem>18</asp:listitem>

<asp:listitem>26</asp:listitem>

<asp:listitem>36</asp:listitem>

<asp:listitem>48</asp:listitem>

<asp:listitem>62</asp:listitem>

</asp:dropdownlist>

<asp:button text="update image" onclick="updatebtn_click" runat=server/>

</h3>

</asp:panel>

</form>

</body>

</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » ASP+上传文件语法
分享到: 更多 (0)