<form id="form1" action="Default.aspx" enctype="mutltipart/form-data" method="post" >
<div>
<table width="400" border="1">
<tr>
<td colspan="2" align="center">
添加友情链接
</td>
</tr>
<tr>
<td>
公司名字:
</td>
<td>
<input type="text" id="txtName" name="txtName"/>
</td>
</tr>
<tr>
<td>
网站路径:
</td>
<td>
<input type="text" id="txtPath" name="txtPath" value="http://"/>
</td>
</tr>
<tr>
<td>
上传图片:
</td>
<td>
<input type="file" id="file1" name="file1" />
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" value="确定" />
</td>
</tr>
</table>
</body>
</from>
Default.aspx.cs 页面不知道怎么写了
求高手解决 给高分
<div>
<table width="400" border="1">
<tr>
<td colspan="2" align="center">
添加友情链接
</td>
</tr>
<tr>
<td>
公司名字:
</td>
<td>
<input type="text" id="txtName" name="txtName"/>
</td>
</tr>
<tr>
<td>
网站路径:
</td>
<td>
<input type="text" id="txtPath" name="txtPath" value="http://"/>
</td>
</tr>
<tr>
<td>
上传图片:
</td>
<td>
<input type="file" id="file1" name="file1" />
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" value="确定" />
</td>
</tr>
</table>
</body>
</from>
Default.aspx.cs 页面不知道怎么写了
求高手解决 给高分
参考
{
if(fileUpload.HasFile)
{
string savePath = Server.MapPath("~/upload/");
if (!System.IO.Directory.Exists(savePath))
{
System.IO.Directory.CreateDirectory(savePath);
}
savePath = savePath + "\\" + fileUpload.FileName;
fileUpload.SaveAs(savePath);//保存文件
}
}
{
var strFile="<input name=\"upload_A\" type='file' class='inputText' style='WIDTH:350px;'/><br/>";
document.getElementById("td_uploadFile").insertAdjacentHTML("beforeEnd",strFile);
}
<td id="td_uploadFile" align="center">
<input id="upload_A" name="upload_A" type="file" class="inputText"
style="width: 350px; display:none;" runat="server" />
</td> HttpFileCollection Files = HttpContext.Current.Request.Files;
for (int i = 0; i < Files.Count; i++)
{ HttpPostedFile PostedFile = Files[i];
if (PostedFile.ContentLength > 0)
{
string FileName = PostedFile.FileName;
string AttachExt = FileName.Substring(FileName.LastIndexOf(".") + 1);
int TotalSize = PostedFile.ContentLength;
}
}
string picture = System.Configuration.ConfigurationManager.AppSettings["Picture"].ToString();
if (this.File1.FileName != "")
{
if (Convert.ToString(Session["Pic1"]) != "")
{
string path1 = Server.MapPath(Convert.ToString(Session["Pic1"]));
File.Delete(path1);
}
divview1.Visible = true;
int MaxLength1 = 1024 * 1024;
string roodom = DateTime.Now.ToString("yyMMddHHmmss");
string name1 = roodom + this.File1.FileName;
string type1 = name1.Substring(name1.LastIndexOf(".") + 1).ToLower();
if (this.File1.PostedFile.ContentLength > MaxLength1)
{
Show("上传文件的大小超过了1MB的最大容量!请压缩后再上传!!");
return;
}
if (type1 == "jpg" || type1 == "bmp" || type1 == "gif" || type1 == "png" || type1 == "jpeg" || type1 == "wmf")
{
string filepath0 = Server.MapPath("Pic/" + name1);
string filepath1 = "Pic/" + name1;
model.PHOTOURL = filepath1;
this.File1.SaveAs(filepath0); }
else
{
Show("你的照片文件格式不符合要求!");
return;
}
}
else if (Session["Pic1"] != null && Convert.ToString(Session["Pic1"]) != "")
{
model.PHOTOURL = Convert.ToString(Session["Pic1"]);
}
else
{
model.PHOTOURL = picture;
}