asp

位置:IT落伍者 >> asp >> 浏览文章

ASP+上传文件语法


发布日期:2020年04月24日
 
ASP+上传文件语法

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

<HTML>

<script language=VB runat=server>

Sub UploadBtn_Click(Sender as Object E as EventArgs)

UploadFilePostedFileSaveAs(ServerMapPath(testjpg))

MyImageImageUrl = testjpg

MyImageVisible = true

End Sub

</script>

<body>

<form enctype=multipart/formdata runat=server>

<h>

选择上传文件: <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 SystemDrawing 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=SystemIO %>

<%@ Import Namespace=SystemDrawing %>

<%@ Import Namespace=SystemDrawingImaging %>

<html>

<script language=C# runat=server>

void UploadBtn_Click(Object sender EventArgs e) {

UploadFilePostedFileSaveAs(ServerMapPath(testjpg));

ImageEditorVisible = true;

}

void UpdateBtn_Click(Object sender EventArgs e) {

SystemDrawingImage image = SystemDrawingImageFromFile(ServerMapPath(testjpg));

SystemDrawingImage newimage = new Bitmap(imageWidth imageHeight PixelFormatFormatbppRGB);

Graphics g = GraphicsFromImage(newimage);

gDrawImage(imageimageWidthimageHeight);

Font f = new Font(Lucida Sans Unicode IntParse(FontSizeSelectedItemText));

Brush b = new SolidBrush(ColorRed);

gDrawString(CaptionText f b );

gDispose();

SystemDrawingImage thumbImage = newimageGetThumbnailImage(IntParse(WidthText)IntParse

(HeightText)null);

imageDispose();

thumbImageSave(ServerMapPath(testjpg) ImageFormatJPEG);

}

</script>

<body>

<form enctype=multipart/formdata runat=server>

<h>

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=testjpg>

<h>

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></asp:listitem>

<asp:listitem></asp:listitem>

<asp:listitem></asp:listitem>

<asp:listitem></asp:listitem>

<asp:listitem></asp:listitem>

<asp:listitem></asp:listitem>

</asp:dropdownlist>

<asp:button Text=Update Image OnClick=UpdateBtn_Click runat=server/>

</h>

</asp:panel>

</form>

</body>

</html>

上一篇:ASP类型网站结合动网论坛会员的方法第1/3页

下一篇:处理ASP数据库被挂马的编程方法