chen2071 2015-03-23 09:47 采纳率: 50%
浏览 1640

net2.0 为何在IIS7.0下显示上传不成功 但在IIS6.0下正常

protected void upload_Click(object sender, EventArgs e)
{
    string text = this.Session["port"].ToString();
    string path = "~/Room_JS/" + text + "/tp/gb/";
    bool flag = false;
    string str = base.Server.MapPath(path);
    if (this.FileUpload1.HasFile)
    {
        string a = Path.GetExtension(this.FileUpload1.FileName).ToLower();
        string[] array = new string[]
        {
            ".gif"
        };
        for (int i = 0; i < array.Length; i++)
        {
            if (a == array[i])
            {
                flag = true;
            }
        }
    }
    if (this.FileUpload1.PostedFile.ContentLength > 3000000)
    {
        flag = false;
        base.Response.Write("<script>alert('文件不能超过3MB');window.location.href='Jsedit_jbshzh_edit.aspx?port=" + text + "';</script>");
    }
    if (flag)
    {
        try
        {
            string fileName = this.FileUpload1.PostedFile.FileName;
            FileInfo fileInfo = new FileInfo(fileName);
            string text2 = DateTime.Now.ToString().Replace("-", "").Replace(" ", "").Replace(":", "") + ".gif";
            this.FileUpload1.SaveAs(str + text2);
            string str2 = text2.Replace(".gif", "");
            string text3 = "gb/" + str2;
            base.Response.Write("<script>alert('图片上传成功,请点击保存修改');</script>");
            this.label1.Text = "文件上传成功";
            this.label2.Text = string.Concat(new object[]
            {
                "<b><font color='red' size ='4'>图标路径</font>:</b>http://",
                base.Request.Url.Host,
                "/room_js/",
                text,
                "/tp/gb/",
                text2,
                "<br /><b>文件大小:</b>",
                this.FileUpload1.PostedFile.ContentLength,
                "字节<br /><b>文件类型:</b>",
                this.FileUpload1.PostedFile.ContentType,
                "<br />"
            });
            this.TextBox3.Text = text3;
        }
        catch (Exception var_12_26C)
        {
            this.label1.Text = "文件上传不成功.";
        }
    }
    else
    {
        this.label1.Text = "只能够上传.gif文件.";
    }
}

  • 写回答

1条回答 默认 最新

  • threenewbee 2015-03-23 10:03
    关注

    是相同的服务器么?检查下是不是权限的问题。

    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作