本人可谓愚钝,看了网上很多帖子,还是没有能解决在点击上传后的到的提示: The given path's format is not supported.
我是这样写的
public static string Upload(HtmlInputFile file,string strPath)
{
string str_newfilename='';
if (file.PostedFile.Filename!=string.Empty)
{
str_newfilename=strPath +file.PostedFile.FileName;
//strPath 已在前边赋值, file 为htmlinputfile object
file.PostedFile.SaveAs(str_newfilename);
}
return str_newfilename;
}
重新看了看,再做了下print, 发现path确实是错了.得到是叠加的path. 所做更改如下
public static string Upload(HtmlInputFile file,string strPath)
{
string str_oldfilename=System.IO.Path.GetFileName(file.PostsedFile.FileName);
string str_newfilename='';
if (str_oldfilename!=string.Empty)
{
str_newfilename=strPath +"/"+str_oldfilename;
file.PostedFile.SaveAs(str_newfilename);
}
return str_newfilename;
}
当然还需要给相应folder写的权限
我是这样写的
public static string Upload(HtmlInputFile file,string strPath)
{
string str_newfilename='';
if (file.PostedFile.Filename!=string.Empty)
{
str_newfilename=strPath +file.PostedFile.FileName;
//strPath 已在前边赋值, file 为htmlinputfile object
file.PostedFile.SaveAs(str_newfilename);
}
return str_newfilename;
}
重新看了看,再做了下print, 发现path确实是错了.得到是叠加的path. 所做更改如下
public static string Upload(HtmlInputFile file,string strPath)
{
string str_oldfilename=System.IO.Path.GetFileName(file.PostsedFile.FileName);
string str_newfilename='';
if (str_oldfilename!=string.Empty)
{
str_newfilename=strPath +"/"+str_oldfilename;
file.PostedFile.SaveAs(str_newfilename);
}
return str_newfilename;
}
当然还需要给相应folder写的权限