图片在客户端上传不了
在服务器可以上传,客户机就不可以上传,有经验的帮帮忙
以下是代码:
照片上传:<input id="filePic" type="file" style="width: 491px" />
<input id="btnOK" type="button" value="上传" onclick="upPics('Img1','filePic');" />
[AjaxPro.AjaxMethod]
public string UpPic(string PicPath)
{
string str = "";
string type = PicPath.Substring(PicPath.LastIndexOf(".")).ToLower();
if (".jpg".Equals(type) || ".bmp".Equals(type) || ".png".Equals(type) || ".gif".Equals(type))
{
try
{
FileInfo fi = new FileInfo(PicPath);
long len = fi.Length;
if (len > 102400)
{
str = "2";
}
else
{
//string PicName = DateTime.Now.ToString("yyyyMMddhhmmss") + type;
string PicName = Guid.NewGuid().ToString() + type;
Bitmap objBitmap = new Bitmap(PicPath);
string PathPicNew = "../images/StuPic/" + PicName;
objBitmap.Save(HttpContext.Current.Server.MapPath(PathPicNew));
objBitmap.Dispose();
str = PicName;
Session["path"] = "../images/StuPic/" + PicName;
}
}
catch
{
str = "3";
}
}
else
{
str = "0";
}
return str;
}
在线等....