首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

上传图片报错!

2014-01-28 
上传图片报错,希望各位高手都来帮我看看!!! private void btnPostUpImage_Click(object sender, System.Eve

上传图片报错,希望各位高手都来帮我看看!!!
private void btnPostUpImage_Click(object sender, System.EventArgse)
{
string path;
string filename;
int po;
long filesize;
string fType;
if(file1.PostedFile.FileName.Trim()!= " ")
{
try
{
path=Server.MapPath( "..//UpFile ").ToString();
filename=file1.PostedFile.FileName.ToString(); fType=file1.PostedFile.ContentType.ToString();
this.ViewState[ "type "]=fType;
filesize=file1.PostedFile.ContentLength;

po=filename.LastIndexOf((char)92);
filename=filename.Substring(po+1,filename.Length-po-1);
this.ViewState[ "PostFileName "]=filename;
file1.PostedFile.SaveAs(path+ "// "+filename);
this.imageCine.ImageUrl= "..//UpFile// "+filename;
}
catch(Exception ex)
{
this.ShowErrMsg(ex.Message);
}
}

}

错误信息是:
对路径C:InetpubwwwrootWebCinemaServerUpFile的访问被拒绝



------解决方法--------------------------------------------------------
把C:InetpubwwwrootWebCinemaServerUpFile文件夹对IUSR用户开写权限
------解决方法--------------------------------------------------------
路径文件夹WebCinemaServerUpFile 的属性--安全--Everyone权限要是完全控制哦
C:InetpubwwwrootWebCinemaServerUpFile 你这个路径咋没有'\' ?
------解决方法--------------------------------------------------------
感觉你写代码特别喜欢用 ToString这个方法
你看,下面的代码就有N个多余的 ToString

path=Server.MapPath( "..//UpFile ").ToString();//MapPath返回的就是string
filename=file1.PostedFile.FileName.ToString();//FileName属性就是string fType=file1.PostedFile.ContentType.ToString();//上同         

热点排行