c# - 我在实时 Web 服务器中上传图像,服务器响应错误,而图像在 Visual Studio 的本地服务器上成功上传
问题描述
我在 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;
}
解决方案
推荐阅读
- python - python - Yahoo Janan Ads Api 返回丢失的数据
- nestjs - 有没有使用 NestTs 从数据库中检索大文件的解决方案
- typescript - 为什么这个 JSON 模式不能分配给这个 TypeScript 接口?
- javascript - 找不到模块:无法解析“firebase”
- scala - 无法使用 spark scala 读取和写入 kafka 主题
- python - 在python中这是做什么的?x = 函数(参数)(变量)
- javascript - Flutter Firestore 集合相关的下拉菜单
- python - 将多个图一起绘制为子图
- javascript - React Native - JSON中位置0的意外令牌U
- sql - 分别列出分区表名和分区名