环境VS2005 win2003 
在用VS2005调试 上传文件成功。
然后用IIS发布,还是在本机上传文件失败,没有获取到文件。
文件夹权限之类的问题已经考虑到 几乎给了最大权限还是不行。
请教各位了。

解决方案 »

  1.   

        private void UploadPhoto()
        {
            string script = string.Empty;        if ((filPhoto.PostedFile != null) && (filPhoto.PostedFile.ContentLength > 0))
            {
                if (!IsValidImageFile(filPhoto))
                {
                    script = string.Format(SCRIPT_TEMPLATE, "The uploaded file is not a valid image file.", "true");
                }
            }
            else
            {
                script = string.Format(SCRIPT_TEMPLATE, "Please specify a valid file.", "true");
            }        if (string.IsNullOrEmpty(script))
            {
                //Uploaded file is valid, now we can do whatever we like to do, copying it file system,
                //saving it in db etc.            //Your Logic goes here
                //filPhoto.PostedFile.SaveAs(Server.MapPath("") + "upfiles/1.jpg");            string fileName;
                fileName = DateTime.Now.ToFileTime()+System.IO.Path.GetExtension(filPhoto.PostedFile.FileName);
                filPhoto.PostedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("upfiles/") + fileName);            if (Session["upfiles"] != null)
                {
                    Session.Remove("upfiles");
                }            Session.Add("upfiles", "upfiles/" + fileName);            script = string.Format(SCRIPT_TEMPLATE, "Photo uploaded." + fileName, "false");
            }        //Now inject the script which will fire when the page is refreshed.
            ClientScript.RegisterStartupScript(this.GetType(), "uploadNotify", script);
        }
      

  2.   

    楼主附件大小是不是超过了2M,如果2M之内的可以上传,那就是win2003默认限制的缘故了,解决如下:
    1.先在服务里关闭 iis admin service 服务
    2.找到 windows\system32\inetsrv\ 下的 metabase.xml 文件,找到 ASPMaxRequestEntityAllowed 节点修改其值
    3.存盘,然后重启 iis admin service 服务
      

  3.   

    权限给的帐户不对把??
    asp.net帐户给了没?
      

  4.   

    NetSevice,和IIS_WPG都需要给相应的权限
      

  5.   

    upfiles/
    文件夹是否存在?给一个everyone完全控制的权限试试。
      

  6.   

    upfiles/  存在,因为我在VS下调试成功的。
    everyone给了,也不行。
    所有我就没有思路了,哪位可以给个思路,方向。
      

  7.   

    upfiles/  在你发布后的文件夹里是否存在呢?
      

  8.   

    老兄,你把
    if (string.IsNullOrEmpty(script))
    这个条件去掉看看
      

  9.   

    最后一直显示 Please specify a valid file.
    也就是 这条语句为 false 
    if ((filPhoto.PostedFile != null) && (filPhoto.PostedFile.ContentLength > 0))程序没有报错。
      

  10.   

    在IIS下 上传好像没有 取到文件,所以显示 Please specify a valid file. 
    原因是什么呢
      

  11.   

    在IIS下 上传好像没有 取到文件,所以显示 Please specify a valid file. 
    原因是什么呢
      

  12.   

    看看html视图
    <form id="frmUpload" method="post" enctype="multipart/form-data" runat="server">
    有没有enctype="multipart/form-data"