html中自动填写控件,html控件自动点 “加号”添加 多个附件

HTML:

JS:

var ti = 1;

function btnAddAttTI() {

ti += 1;

            $("#divTI").append("

‘删除附件‘
")

}

function deleteTI(tiid) {

$("#divTI" + tiid + "").remove();

}

c#

///

/// 上传附件

///

///

private bool UploadAtt(string pId, string htNo)

{

bool R = false;

HttpFileCollection files = HttpContext.Current.Request.Files;

string pathML = "", pathTI = "", pathCK = "", pathZB = "", pathXHT = "", pathYS = "";

string dML = "", dTI = "", dCK = "", dZB = "", dXHT = "", dYS = "";

#region 创建保存附件目录

if (files.Count != 0)

{

string path = Server.MapPath("UploadFile");

pathML = path + "/" + pid + "/" + htno + "/ml";

dML = "BusinessUploadFile/" + pid + "/" + htno + "/ml";

//创建目录

if (!Directory.Exists(path + "/" + pid + "/" + htno + "/ml"))

{

Directory.CreateDirectory(path + "/" + pid + "/" + htno + "/ml");

}

}

#endregion

int BZ = 0;

for (int iFile = 0; iFile < files.Count; iFile++)

{

HttpPostedFile postedFile = files[iFile];

if (!string.IsNullOrEmpty(postedFile.FileName))

{

BZ = 1;

string fileName = "";//定义文件名

fileName = Path.GetFileName(postedFile.FileName);//得到上传文件的完整名称 即文件名+后缀名

//int index = fileName.IndexOf(".");

string tempPath = "", dPath = "", ctype = ""; ;

if (files.AllKeys[iFile].IndexOf("FileML") > -1)

{

tempPath = pathML;

dPath = dML;

ctype = "ML";

}

string mypath = tempPath + "/" + fileName;

try

{

postedFile.SaveAs(mypath);   //保存附件

//添加附件信息数据

BusinessAttModel uam = new BusinessAttModel();

uam.AttName = fileName.Substring(0, fileName.IndexOf(‘.‘));

uam.ProjectId = int.Parse(pId);

uam.AttPath = dPath + "/" + fileName;

uam.EmployeeID = Session["LoginUser"].ToString();

uam.CHTNo = htNo;

uam.CType = ctype;

PB.BusinessSaveAtt(uam);

R = true;

}

catch (Exception ex)

{

PB.DeleteBusinessAtt(pId, htNo, ctype);  //捕获到异常就删除当前附件的记录 遗留附件没关系,在上传可以覆盖

R = false;

break;

}

}

}

if (BZ == 0)   //没上传附件

{

R = true;

}

return R;

}

原文:http://www.cnblogs.com/PeaCode/p/3881408.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值