【问题标题】:How to handle File Upload by Appweb with Ejscript如何使用 Ejscript 处理 Appweb 上传的文件
【发布时间】:2012-11-29 08:18:01
【问题描述】:

我的网络应用程序部署在嵌入式 linux 上,我使用 AppWeb 作为网络服务器。 我使用了 Appweb 3.3.2 和 Ejscript 1.1.2

现在,我想通过网络浏览器将文件上传到服务器。在 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 

谁能帮帮我,请... 谁能给我一个示例ejscript页面来保存文件上传到服务器...

谢谢,

提达斯勒

【问题讨论】:

    标签: web-services file-upload upload serverside-javascript ejs


    【解决方案1】:

    您不应该创建自己的 Request 对象。这是为您创建的,可在“请求”变量中访问。

    你可以这样做:

    写(request.files.upfile.size)

    我还建议您升级到 Appweb 4 和 Ejscript 2。更加灵活。

    【讨论】:

    • 当我做我的项目时,Appweb 4 和 Ejs 2 不稳定。所以我选择了稳定版^^。谢谢你的推荐
    猜你喜欢
    • 2012-04-23
    • 1970-01-01
    • 2012-05-22
    • 1970-01-01
    • 2017-06-09
    • 2012-06-30
    • 2016-02-07
    • 2021-07-12
    • 2011-01-15
    相关资源
    最近更新 更多