大家有没有好的图片上传实例啊(C#),大家知道的推荐一下 http://dotnet.aspx.cc/ShowDetail.aspx?id=2A5DD7C6-A45A-48AB-A2E8-342A29F17506http://dotnet.aspx.cc/ShowDetail.aspx?id=ECD9AE16-8FF0-4A1C-9B9F-5E8B641CB1B1 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/aspnet-fileupload.asphttp://www.ondotnet.com/pub/a/dotnet/2002/04/01/asp.htmlhttp://www.developer.com/net/asp/article.php/3097661http://www.codeproject.com/aspnet/FileUploadProgressBar.asphttp://www.stardeveloper.com/articles/display.html?article=2003022601&page=1 <%@ Page Language="c#" Debug="true" Trace="true"%><%@ Import Namespace="System.IO" %><%@ Import Namespace="System.Drawing" %><%@ Import Namespace="System.Drawing.Imaging" %><html><script runat =server> void UploadBtn_Click(Object sender, EventArgs e) { String filename; String filename1; String[] filename2; int q; filename=UploadFile.PostedFile.FileName ; filename2=filename.Split(new Char[] {'\\'}); q=filename2.GetUpperBound(0); filename1=filename2[q]; dis.Text="上传文件名:"+filename1+"<br/>"; UploadFile.PostedFile.SaveAs(Server.MapPath(filename1)); ImageEditor.Visible = true; dis.Text+="文件大小:"+UploadFile.PostedFile.ContentLength+"字节数"; Image1.Src=filename1; } void UpdateBtn_Click(Object sender, EventArgs e) { String filename1; filename1=Image1.Src; System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(filename1)); 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(FontType.SelectedItem.Text, 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(Convert.ToInt32(Width.Text),Convert.ToInt32(Height.Text),null,0); image.Dispose(); // thumbImage.Save(Server.MapPath(filename1), ImageFormat.Jpeg); Image1.Src=filename1; Caption.Text=""; } </script> <body> <asp:label id="dis" runat=server/> <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 ID="Image1" src="" runat="server"/> <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> Caption Font: <asp:dropdownlist id="FontType" 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/> </h3> </asp:panel> </form> </body></html> <%@ Page Language="c#" Debug="true" Trace="true"%><%@ Import Namespace="System.IO" %><html><head><script runat="server"> void SubmitButton_Click(Object sender, EventArgs e) { if (File1.PostedFile != null) { try { File1.PostedFile.SaveAs("E:/hnb/"); //File1.PostedFile.SaveAs(Request.PhysicalApplicationpath); Span1.InnerHtml = "Upload Successful!"; } catch (Exception ex) { Span1.InnerHtml = "Error saving file <b>C:\\" + File1.Value + "</b><br>" + ex.ToString(); } } } </script></head><body> <form runat="server" enctype="multipart/form-data"> Select a file to upload:<br /> <input type="file" id="File1" runat="Server"> <p> <input type="submit" id="Submit1" runat="Server" value="Upload File" OnServerClick="SubmitButton_Click"> <p> <span id="Span1" runat="Server" /> </form></body></html>大家看一下这段代码错在哪里呢 lihonggen0(李洪根,MS MVP,标准答案来了)很久没看见你了! to lxcc(虫子):我经常上的呀!你可以在vb论坛和.net部分见到最近在做一个2000万的大项目.电信的 File1.PostedFile.SaveAs("E:/hnb/文件名"); File1.PostedFile.SaveAs("C:\\Uploads\\uploadedfile.txt");你必须保证有这个目录 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuihtmlcontrolshtmlinputfileclasspostedfiletopic.asp <%@ Page Language="C#" AutoEventWireup="True" %><html> <head> <script language="C#" runat="server"> void Button1_Click(object Source, EventArgs e) { if (Text1.Value == "") { Span1.InnerHtml = "Error: you must enter a file name"; return; } if (File1.PostedFile != null) { try { File1.PostedFile.SaveAs("c:\\temp\\"+Text1.Value); Span1.InnerHtml = "File uploaded successfully to <b>c:\\temp\\" + Text1.Value + "</b> on the Web server"; } catch (Exception exc) { Span1.InnerHtml = "Error saving file <b>c:\\temp\\" + Text1.Value + "</b><br>" + exc.ToString(); } } } </script> </head> <body> <h3>HtmlInputFile Sample</h3> <form enctype="multipart/form-data" runat="server"> Select File to Upload: <input id="File1" type="file" maxlength="30" runat="server"/> <p/> Save as filename (no path): <input id="Text1" type="text" runat="server"/> <p/> <span id="Span1" style="font: 8pt verdana;" runat="server" /> <p/> <input type="button" id="Button1" value="Upload" OnServerClick="Button1_Click" runat="server"> </form> </body> </html> 问个问题? PopupWin控件的Message属性能不能显示多条信息? DataGrid 有一个字段是绑定行数的,比如说第一行,Grid的这个字段就现实1,怎么实现呢? 问一个实在是送分的问题 一种排列方式的写法求救,不胜感激~~~~~~~~~~~~~~ Microsoft Visual Studio 2005 Professional DVD版本(bt下载) 如何保存各分页的数据 关于ASP.NET的VB基本知识 换环境后出现的问题 请问下,.net下上传比较大的文件,视频,用什么比较好? 原来如此呀,那怎么搞才好呢 100分求解的问题,不够再加
http://www.ondotnet.com/pub/a/dotnet/2002/04/01/asp.html
http://www.developer.com/net/asp/article.php/3097661
http://www.codeproject.com/aspnet/FileUploadProgressBar.asp
http://www.stardeveloper.com/articles/display.html?article=2003022601&page=1
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<html>
<script runat =server>
void UploadBtn_Click(Object sender, EventArgs e) {
String filename;
String filename1;
String[] filename2;
int q;
filename=UploadFile.PostedFile.FileName ;
filename2=filename.Split(new Char[] {'\\'});
q=filename2.GetUpperBound(0);
filename1=filename2[q];
dis.Text="上传文件名:"+filename1+"<br/>";
UploadFile.PostedFile.SaveAs(Server.MapPath(filename1));
ImageEditor.Visible = true;
dis.Text+="文件大小:"+UploadFile.PostedFile.ContentLength+"字节数";
Image1.Src=filename1;
}
void UpdateBtn_Click(Object sender, EventArgs e) {
String filename1;
filename1=Image1.Src;
System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(filename1));
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(FontType.SelectedItem.Text, 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(Convert.ToInt32(Width.Text),Convert.ToInt32(Height.Text),null,0);
image.Dispose();
// thumbImage.Save(Server.MapPath(filename1), ImageFormat.Jpeg);
Image1.Src=filename1;
Caption.Text="";
} </script> <body>
<asp:label id="dis" runat=server/>
<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 ID="Image1" src="" runat="server"/> <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>
Caption Font: <asp:dropdownlist id="FontType" 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/> </h3>
</asp:panel> </form> </body>
</html>
<%@ Import Namespace="System.IO" %>
<html>
<head>
<script runat="server"> void SubmitButton_Click(Object sender, EventArgs e) {
if (File1.PostedFile != null) {
try {
File1.PostedFile.SaveAs("E:/hnb/");
//File1.PostedFile.SaveAs(Request.PhysicalApplicationpath);
Span1.InnerHtml = "Upload Successful!";
}
catch (Exception ex) {
Span1.InnerHtml = "Error saving file <b>C:\\" +
File1.Value + "</b><br>" + ex.ToString();
}
}
} </script>
</head>
<body>
<form runat="server" enctype="multipart/form-data">
Select a file to upload:<br />
<input type="file" id="File1" runat="Server">
<p>
<input type="submit" id="Submit1" runat="Server"
value="Upload File" OnServerClick="SubmitButton_Click">
<p>
<span id="Span1" runat="Server" />
</form>
</body>
</html>
大家看一下这段代码错在哪里呢
很久没看见你了!
<head>
<script language="C#" runat="server">
void Button1_Click(object Source, EventArgs e)
{
if (Text1.Value == "")
{
Span1.InnerHtml = "Error: you must enter a file name";
return;
}
if (File1.PostedFile != null)
{
try
{
File1.PostedFile.SaveAs("c:\\temp\\"+Text1.Value);
Span1.InnerHtml = "File uploaded successfully to <b>c:\\temp\\" +
Text1.Value + "</b> on the Web server";
}
catch (Exception exc)
{
Span1.InnerHtml = "Error saving file <b>c:\\temp\\" +
Text1.Value + "</b><br>" + exc.ToString();
}
}
}
</script>
</head>
<body>
<h3>HtmlInputFile Sample</h3>
<form enctype="multipart/form-data" runat="server">
Select File to Upload:
<input id="File1"
type="file"
maxlength="30"
runat="server"/>
<p/>
Save as filename (no path):
<input id="Text1"
type="text"
runat="server"/>
<p/>
<span id="Span1"
style="font: 8pt verdana;"
runat="server" />
<p/>
<input type="button"
id="Button1"
value="Upload"
OnServerClick="Button1_Click"
runat="server">
</form>
</body>
</html>