返回顶部

收藏

.net 接受上传文件的代码

更多
if (Request.Files.Count != 0)
{
    HttpPostedFile MyUpFile = Request.Files["file"];

    if (!string.IsNullOrEmpty(MyUpFile.FileName))
    {
        string fileName=Path.GetFileName(MyUpFile.FileName);
        filePath = ConfigurationManager.AppSettings["AttPath"] + "/Accessories/";
        filePath = filePath + project.ProjectID + "/";
        string folder = Function.CreateRandomDirectoryFolder(filePath) + "/";
        filePath = filePath + folder;
        filePath = filePath + fileName;
        MyUpFile.SaveAs(filePath);
        url = ConfigurationManager.AppSettings["AttUrl"];
        url += "/Accessories/" + project.ProjectID + "/" + folder + fileName;
    }
}
//该片段来自于http://outofmemory.cn

标签:c#,.net,网络

收藏

0人收藏

支持

0

反对

0