333
This commit is contained in:
34
MyCode.Project.Infrastructure/Common/UploadFile.cs
Normal file
34
MyCode.Project.Infrastructure/Common/UploadFile.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace MyCode.Project.Infrastructure.Common
|
||||
{
|
||||
public class UploadFile
|
||||
{
|
||||
|
||||
public static string Upload(HttpPostedFile file, string uploadPath)
|
||||
{
|
||||
try
|
||||
{
|
||||
var path = HttpContext.Current.Server.MapPath(uploadPath + file.FileName);
|
||||
if (!Directory.Exists(HttpContext.Current.Server.MapPath(uploadPath)))
|
||||
{
|
||||
Directory.CreateDirectory(uploadPath);
|
||||
}
|
||||
file.SaveAs(path);
|
||||
return path;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "error";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user