日期:2014-05-17 浏览次数:20638 次
function getFileName() {
var path = document.getElementById("Main_FileUpload1").value;
var pos1 = path.lastIndexOf("\\");
var pos2 = path.lastIndexOf(".");
var pos = path.substring(pos1 + 1, pos2);
alert(pos);
var xhr = createXhr();
xhr.open("get", "AjaxTest.ashx?name=" + pos, true);
xhr.setRequestHeader("contentType", "application/x-www-form-urlencoded; charset=UTF-8");
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.responseText == "y") {
alert(xhr.responseText);
} else {
alert(xhr.responseText);
}
}
}
xhr.send(null);
}
<%@ WebHandler Language="C#" Class="AjaxTest" %>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Haiyang.DAL;
using System.IO;