我在Asp.net mvc中开发了一个网站,并将数据存储在sql server数据库中 . 我正在上传图像,在项目文件夹目录中,图像在数据库中的本地服务器上成功上传 .
但问题是,当我上传图像时,实时服务器出错,我已经购买了共享服务器,我已经部署了我的网站 .
下面的代码用于保存图像,它在本地服务器上正常工作,但它在实时服务器上出错 .
public string SaveImagingData(string fileName, HttpPostedFileBase image)
{
// your configuration here...
string miliSec = DateTime.Now.Ticks.ToString();
string imageName = null;
string physicalPath = "~/Content/images/";
if (image != null && image.ContentLength > 0)
{
imageName = Regex.Replace(fileName, @"\s", "_") + "_" + miliSec + Path.GetExtension(Path.GetFileName(image.FileName));
string path = Server.MapPath(physicalPath + imageName);
// save image in folder
image.SaveAs(path);
}
return imageName;
}