ajaxfileupload源碼
解決上傳成功不走success的問題
解決高版本jquery兼容性問題
jQuery.extend({
createUploadIframe: function(id, uri)
{
//create frame
var frameId = 'jUploadFrame' + id;
var iframeHtml = '<iframe id="' + frameId + '" name="' + frameId + '">附html代碼和服務端代碼
<input type="file" id="importFile" name="importFile" accept="text/plain" />
#region 上傳文件 讀取導入的內容
public JsonResult Upload()
{
HttpFileCollectionBase hfc = Request.Files;
string Path = "";
List<LgtdAndLttd> list = new List<LgtdAndLttd>();
string PhysicalPath = "";
if (hfc.Count > 0)
{
if (hfc[0].FileName.Contains("\\"))
{
int index = hfc[0].FileName.LastIndexOf('\\');
Path = "/Upload" +hfc[0].FileName.Substring(index, hfc[0].FileName.Length - index);
}
else
Path = "/Upload/" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff") + System.IO.Path.GetFileName(hfc[0].FileName);
PhysicalPath = Server.MapPath(Path);
hfc[0].SaveAs(PhysicalPath);
StreamReader sr = new StreamReader(PhysicalPath);
LgtdAndLttd sta = new LgtdAndLttd();
while(sr.Peek()>=0)
{
sta.LGTD = sr.ReadLine().Split('|')[0];
sta.LTTD = sr.ReadLine().Split('|')[1];
list.Add(sta);
}
}
return Json(list);
}
#endregion