HttpPostedFile.SaveAs错误,根路径? [英] HttpPostedFile.SaveAs error, rooted path?

查看:307
本文介绍了HttpPostedFile.SaveAs错误,根路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HttpPostedFile对象,当我尝试通过SaveAs保存它得到这个异常System.Web.HttpException

I have an HttpPostedFile object, when I try saving it via SaveAs I get this exception System.Web.HttpException


SaveAs方法被配置为需要根路径,并且路径./tempUpload/4没有rooted。

The SaveAs method is configured to require a rooted path, and the path './tempUpload/4' is not rooted.

为什么?

推荐答案

路径应该是绝对路径,而不是相对URL。

The path should be an absolute path, not a relative url.

使用 Server.MapPath 方法从相对URL获取绝对路径。

Use the Server.MapPath method to get the absolute path from your relative url.

这篇关于HttpPostedFile.SaveAs错误,根路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆