$.ajax({
type: "POST", //訪問WebService使用Post方式請求
contentType: "application/json",
url: "UpdateNews.aspx/InsertLocalImages",
data: "{dirName:'" + UploadPath + "',ImagePath:'" + imgpath + "',ImageName:'" + imgname + "',filetitle:'" + title + "',filedate:'" + date + "',fileexp:'" + exp + "',filekeyw:'" + keyw + "',iscovr:'" + iscovr + "'}",
dataType: 'json',
success: function(result) {//回呼函數,result,傳回值
if (result.d != "") {
//在游標處插入圖片
InsertImage(result.d, id);
Dialog.alert("本地圖片入庫成功", function() { Dialog.close(); });
}
else {
Dialog.alert("本地圖片入庫失敗");
}
},
error: function() {
Dialog.alert("本地圖片入庫失敗");
},
beforeSend: function() {
UploadLocalLoading.style.display = "block"; //顯示提示資訊;
},
complete: function() {
UploadLocalLoading.style.display = "none"; //影藏提示資訊;
}
});
//後台代碼
[WebMethod]
public static string InsertLocalImages(string dirName, string ImagePath, string ImageName, string filetitle, string filedate, string fileexp, string filekeyw, string iscovr)
{
string LocalImagePath = ImagePath;//本地圖片路徑
string ImageUrlPath = "";//返回圖片的URL路徑
//上傳圖片
if (LocalImagePath != "")
{
ImageUrlPath = Upload(dirName, LocalImagePath, ImageName, filetitle, filedate, fileexp, filekeyw, iscovr == "true" ? true : false);
}
return ImageUrlPath;
}