怎么样在ASP.NET里面实现文件的上传下载?给出全部代码再加一百 这里讲得很明白:http://www.ondotnet.com/pub/a/dotnet/2002/04/01/asp.html?page=1 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <%@ Page Language="C#" Debug="true" %><%@ import Namespace="System.IO" %><%@ import Namespace="System.Drawing" %><%@ import Namespace="System.Drawing.Imaging" %><script runat="server"> void UploadBtn_Click(Object sender, EventArgs e) { /* string strpath=UploadFile.Value; int i=strpath.Length; while(i>0){ char ch=strpath[i-1]; if(ch=='\\' || ch=='/' || ch==':') break; i--; } string filename=strpath.Substring(i); Button1.Text=filename; return; */ 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,IntPtr.Zero); image.Dispose(); thumbImage.Save(Server.MapPath("test.jpg"), ImageFormat.Jpeg); }</script><html><head></head><body> <form enctype="multipart/form-data" runat="server"> <h3>选择要上载的文件: <input id="UploadFile" type="file" name="file2" runat="server" /> <asp:button id="Button1" onclick="UploadBtn_Click" runat="server" text="Upload Me!"></asp:button> <hr /> <asp:panel id="ImageEditor" runat="server" visible="false"> <img src="test.jpg" /> <h3>图象的宽度: <asp:textbox id="Width" runat="server"></asp:textbox> 图象的高度: <asp:textbox id="Height" runat="server"></asp:textbox> <br /> 文字的内容: <asp:textbox id="Caption" runat="server"></asp:textbox> 文字的大小: <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 id="Button2" onclick="UpdateBtn_Click" runat="server" text="Update Image"></asp:button> </h3> </asp:panel> </h3> </form></body></html> SQL Server 怎么查询在某数据库中哪个表占用空间最大? 怎样获得当前页和上一页的地址? 7号信令 如何往XML里添加数据? 网址显示问题 vs2005在前台javascript中怎么调用这个页面的Button1的按钮事件 IE分页打印 问个很低级的问题 ifram问题 如何实现panel拖动效果 asp.net运行需要哪些权限?急 请问怎样使DIV可以这样?
<%@ import Namespace="System.IO" %>
<%@ import Namespace="System.Drawing" %>
<%@ import Namespace="System.Drawing.Imaging" %>
<script runat="server"> void UploadBtn_Click(Object sender, EventArgs e)
{
/* string strpath=UploadFile.Value;
int i=strpath.Length;
while(i>0){
char ch=strpath[i-1];
if(ch=='\\' || ch=='/' || ch==':') break;
i--;
}
string filename=strpath.Substring(i);
Button1.Text=filename;
return; */
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,IntPtr.Zero);
image.Dispose();
thumbImage.Save(Server.MapPath("test.jpg"), ImageFormat.Jpeg);
}</script>
<html>
<head>
</head>
<body>
<form enctype="multipart/form-data" runat="server">
<h3>选择要上载的文件:
<input id="UploadFile" type="file" name="file2" runat="server" />
<asp:button id="Button1" onclick="UploadBtn_Click" runat="server" text="Upload Me!"></asp:button>
<hr />
<asp:panel id="ImageEditor" runat="server" visible="false">
<img src="test.jpg" />
<h3>图象的宽度:
<asp:textbox id="Width" runat="server"></asp:textbox>
图象的高度:
<asp:textbox id="Height" runat="server"></asp:textbox>
<br />
文字的内容:
<asp:textbox id="Caption" runat="server"></asp:textbox>
文字的大小:
<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 id="Button2" onclick="UpdateBtn_Click" runat="server" text="Update Image"></asp:button>
</h3>
</asp:panel>
</h3>
</form>
</body>
</html>