专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > DotNet Exception

上传图片报错!

发布时间:2011-06-26 20:23:37 文章来源:www.iduyao.cn 采编人员:星星草

上传图片报错,希望各位高手都来帮我看看!!!
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();//上同

友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: