展开全部
无语。。。winform程序不是一样的吗?
private string uploadFile(FileUpload hiFile) //FileUpload是控件
{
string clientFileName = hiFile.PostedFile.FileName;
string strExtension = clientFileName.Substring(clientFileName.LastIndexOf("."));
string timePath = DateTime.Now.ToString("yyyyMM") + "/";
string serverFileNmae = l02StaffInfo.USERID + "_" + DateTime.Now.ToString("yyyyMMddhhmmssfff") + "_" + uploadCount + strExtension;
string absolutePath = Server.MapPath(PRO_FILE_ABPATH + timePath);//PRO_FILE_ABPATH固定路径,自己定义吧
UploadFile(hiFile, absolutePath, serverFileNmae);
return timePath + serverFileNmae;
}
public void UploadFile(FileUpload hifile, string absolutePath, string serverFileName)
{
//如果路径不存在则创建
if (!Directory.Exists(absolutePath))
{
Directory.CreateDirectory(absolutePath);
}
hifile.PostedFile.SaveAs(absolutePath + serverFileName);
}
private string uploadFile(FileUpload hiFile) //FileUpload是控件
{
string clientFileName = hiFile.PostedFile.FileName;
string strExtension = clientFileName.Substring(clientFileName.LastIndexOf("."));
string timePath = DateTime.Now.ToString("yyyyMM") + "/";
string serverFileNmae = l02StaffInfo.USERID + "_" + DateTime.Now.ToString("yyyyMMddhhmmssfff") + "_" + uploadCount + strExtension;
string absolutePath = Server.MapPath(PRO_FILE_ABPATH + timePath);//PRO_FILE_ABPATH固定路径,自己定义吧
UploadFile(hiFile, absolutePath, serverFileNmae);
return timePath + serverFileNmae;
}
public void UploadFile(FileUpload hifile, string absolutePath, string serverFileName)
{
//如果路径不存在则创建
if (!Directory.Exists(absolutePath))
{
Directory.CreateDirectory(absolutePath);
}
hifile.PostedFile.SaveAs(absolutePath + serverFileName);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询