老来哥 2018-08-21 06:28 采纳率: 50%
浏览 774
已采纳

fileupload本地图片上传成功,上传到主机后出错

上传代码:
if(FileUpload1.HasFile)
{
string FullName = FileUpload1.PostedFile.FileName;//获取图片物理地址
FileInfo fi = new FileInfo(FullName);
string name = fi.Name;//获取图片名称
string type = fi.Extension;//获取图片类型
string ImageTitle = TextBox1.Text;
if (type == ".jpg" || type == ".gif" || type == ".bmp" || type == ".png")
{
string filename = FileUpload1.FileName;
string fileext = System.IO.Path.GetExtension(filename);
string filenamaes = "xiangce" + DateTime.Now.ToString("yyyyMMddHHffss") + fileext;
fengmian_name = filenamaes;

            string SavePath = Server.MapPath("~\\ftp6247338\\Web\\picpage\\images");//图片保存到文件夹下
            this.FileUpload1.PostedFile.SaveAs(SavePath + "\\" + fengmian_name);//保存路径
            this.Image9.Visible = true;
            this.Image9.ImageUrl = "~\\ftp6247338\\Web\\picpage\\images" + "\\" + fengmian_name;//界面显示图片
            //string pic_addtime = DateTime.Now.ToString("yyyy/MM/dd");

            fengmian_addr = "../ftp6247338/Web/picpage/images/" + fengmian_name;
            admin_fengmian_addr = "~\\ftp6247338\\Web\\picpage\\images" + "\\" + fengmian_name;
            //fengmian_name = name ;
        }
        else
        {
            this.label6.Text = "请选择正确的格式图片";
        }

错误类型:

“/”应用程序中的服务器错误。

安全性异常
说明: 应用程序尝试执行安全策略不允许的操作。要授予此应用程序所需的权限,请与系统管理员联系,或在配置文件中更改该应用程序的信任级别。

异常详细信息: System.Security.SecurityException: 请求“System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”类型的权限已失败。

源错误:

行 267: {
行 268: string FullName = FileUpload1.PostedFile.FileName;//获取图片物理地址
行 269: FileInfo fi = new FileInfo(FullName);
行 270: string name = fi.Name;//获取图片名称
行 271: string type = fi.Extension;//获取图片类型

源文件: d:\localuser\ftp6247338\Web\picpage\xiangce_add.aspx.cs 行: 269

堆栈跟踪:

[SecurityException: 请求“System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”类型的权限已失败。]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +31
System.Security.CodeAccessPermission.Demand() +46
System.IO.FileInfo.Init(String fileName, Boolean checkHost) +116
System.IO.FileInfo..ctor(String fileName) +45
picpage_xiangce_add.Button1_Click(Object sender, EventArgs e) in d:\localuser\ftp6247338\Web\picpage\xiangce_add.aspx.cs:269
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9615682
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6704
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +245
System.Web.UI.Page.ProcessRequest() +72
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +58
ASP.picpage_xiangce_add_aspx.ProcessRequest(HttpContext context) in App_Web_yfh1enol.2.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

  • 写回答

2条回答 默认 最新

  • threenewbee 2018-08-21 08:12
    关注

    明显是权限问题,请求“System.Security.Permissions.FileIOPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”类型的权限已失败。

    具体你要把你的服务器的地址、用户名密码私信给我。我可以帮你调下。因为是你环境的问题,你管理员又太菜,所以这么问肯定很难直接帮助到你

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R