日期:2014-05-17 浏览次数:21185 次
private String typename(FileUpload fileloads)
{
string fullfilename = fileloads.PostedFile.FileName; ;// 客户端文件路径
string filename = fullfilename.Substring(fullfilename.LastIndexOf("\\") + 1);
string type = fullfilename.Substring(fullfilename.LastIndexOf(".") + 1);
string murl = "";
if (FileUpload1.HasFile)
{
if (type == "xls" || type == "xlsx")
{
fileloads.PostedFile.SaveAs(Server.MapPath("Excel") + "\\" + filename);
murl = (Server.MapPath("Excel") + "\\" + filename).ToString();
}
else
{
Response.Write("<script language='javascript'>alert('导入文件格式不对!');</script>");
}
return murl;
}
else
{
// Notify the user that a file was not uploaded.
Response.Write("<script language='javascript'>alert('You did not specify a file to upload!');</script>");