为什么上传不了图片到文件夹?
要把一个图片上传到UpFile文件夹,是文件夹的共享设置还是什么问题?代码如下,哪位给看看如何改?
private void btn_PostUp_Click(object sender, System.EventArgs e)
{
string Path;
string FileName;
int Po;
long FileSize;
string fType;
if(File1.PostedFile.FileName.Trim()!="")
{
try
{
Path=Server.MapPath("\\BookShop\\UpFile").ToString();
FileName=File1.PostedFile.FileName.ToString();
fType=File1.PostedFile.ContentType;
FileSize=File1.PostedFile.ContentLength;
if(fType.Substring(0,5)!="image")
{
ShowErrMsg("PostFile is not Image!");
return;
}
Po=FileName.LastIndexOf((char)92);
FileName=FileName.Substring(Po+1,FileName.Length -Po-1);
ViewState["PostFileName"]=FileName;
File1.PostedFile.SaveAs(Path+"\\"+FileName);
img_BookImg.ImageUrl="UpFile\\"+FileName;
}
catch(Exception er)
{
ShowErrMsg(er.Message);
}
}
}