2012-07-26 140 views
0

我的網絡應用程序部署在嵌入式Linux上,我使用AppWeb作爲網絡服務器。 我用Appweb 3.3.2,用Ejscript 1.1.2如何通過Appweb使用Ejscript處理文件上傳

現在,我想通過網頁瀏覽器上傳文件到服務器。在Ejscript的文檔(http://www.ejscript.org/products/ejs/doc-1/api/ejscript/index.html)中,我可以使用Request.files獲取文件上傳的緩衝區。

但是,當我使用Request.files,它有一個錯誤的對象NULL

還有就是我的簡單的頁面,上傳HTML:

<html> 
    <head> 
     <title>Time Attendance Web Control</title> 
    </head> 
    <body> 
     <form method="post" enctype="multipart/form-data" action="upFile.ejs"> 
      Database to upload: <input type="file" name="upfile"> 
      <br> 
      <input type="submit" value="Upload"> 
     </form> 
    </body> 
</html> 

而且ejscript的頁面來處理:upFile.ejs

<% 
    var rq = new Request(); 
    write(rq.files['upfile'].size); // I just write simple code to debug 
%> 

這是錯誤我:

Error rendering: "upFile.ejs". 

Object reference is null 
Stack: 
[00] upFile.es, _Solo_upFileView.render, line 10 -> write(rq.files['upfile'].size); // I just write simple code to debug 
[01] script, Controller.renderView, line 0 

人幫助我,PLZ ...... 以及誰可以給我一個例子ejscript頁面保存文件上傳到服務器...

感謝,

泰達樂

回答

1

你不應該創建你自己的Request對象。這是爲您創建的,並可在「請求」變量中訪問。

你可以這樣做:

寫(request.files.upfile.size)

我也建議您升級到Appweb 4和Ejscript 2.靈活得多。

+0

當我做了我的項目,Appweb 4和Ejs 2並不穩定。所以我選擇了穩定版本^^。感謝您的推薦 – TidusLe 2013-06-17 11:40:08