要把一个图片上传到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);
}
}
}
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);
}
}
}
解决方案 »
- vs2005里有XElement类吗?
- IE6——————magicajax,AjaxPanel 问题——————牛人来~![
- 请问...可以在ascx文件中添加自定义控件吗...?
- 为什么我的datagrid.pagecount总是0,我快疯了,整整弄了三天分页(我以发过,可是还是没解决!!)
- ***一个简单的问题(在线等,谢谢!)***
- 操作POP3协议实现邮件接受,出现问题
- 如何在*.aspx页面中执行自己的*.EXE程序?
- 谁知此段程序是什么意思????
- “系统消息“功能模块,跪求源代码?解决马上结账!!!多谢各位! 急。。。
- 新装的服务器报错
- 动态生成的file文件上传框的怪问题,请大侠帮忙.....
- 大家做趋势图一般怎么做?
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);
}
}
}