25
九月
2008

jQuery.Form Plugin + ASP 上傳檔案

最近開發專案,透過jQuery.Form Plugin搭配ASPupload上傳元件時發生

此欄位如有選取檔案可上傳,未選取檔案反而程式就會過不了的問題

公司同事很堅持是因為jQuery Form 沒有參數設定 enctype=”multipart/form-data”
但感覺上似乎問題方向似乎不是這個,因為檔案是可上傳的

印象中有看過AjaxUpload上傳似乎要透過iframe的方式

建立一個隱形的 iframe,把表單的所有 element 給 clone 到 iframe 內,再進行 submit 的動作。submit 完以後結果再從 iframe 拉回來。

找了一下jQuery.Form API
試看看在Option 部份加入 iframe: true

var options = { 
  beforeSubmit: checkValue,
  success: Response,
  url: 'xxx.asp',
  type: 'post',
  iframe: true
};

打完收工 :)

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

仍無迴響。

發表迴響

(必)

(必)