- /// <summary>
- /// 图片上传
- /// </summary>
- /// <param name="TheFileName">保存的文件名称,不需要后缀</param>
- private Boolean fileUploadImage(string TheFileName)
- {
- bool ges = false;
- string file = "";
- file = fileLogoUrl.PostedFile.FileName;
- string[] end = new string[] { "jpg", "gif", "bmp", "gpg", "gif", "bmp" };//有效文件类型
- if (file.Length != 0)
- {
- string filename = file.Substring(file.LastIndexOf("//") + 1);//取得文件名
- string fileend = file.Substring(file.LastIndexOf(".") + 1);//取得文件类型
- fileend = fileend.ToLower();//后缀转换成小写
- for (int i = 0; i < end.Length; i++)//文件类型是否合法
- {
- if (fileend.Equals(end[i]))
- {
- ges = true;
- }
- }
- if (ges)
- {
- ges = false;
- string filepath = Server.MapPath("../../Upload/FirendLink/") + TheFileName + "." + fileend;
- fileLogoUrl.PostedFile.SaveAs(filepath);
- ges = true;
- }
- else
- {
- ges = false;
- }
- }
- return ges;//返回值判断是否合法
- }