My web apps was deployed on embedded linux, and I used AppWeb as a webserver. I used Appweb 3.3.2, with Ejscript 1.1.2
And now, I want to upload a file by web browser to server. In Ejscript's document (http://www.ejscript.org/products/ejs/doc-1/api/ejscript/index.html), I can use Request.files to get a buffer of file uploaded.
But when I uses Request.files, it had an error object NULL
There is my simple page upload 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>
And ejscript page to handle: upFile.ejs
<%
var rq = new Request();
write(rq.files['upfile'].size); // I just write simple code to debug
%>
And this is error I got:
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
Anybody help me, plz... And who can give me an example ejscript page to save file upload to server...
Thanks,
Tidus Le
You should not be creating your own Request object. That is created for you and accessible in the "request" variable.
You can do:
write(request.files.upfile.size)
I'd also recommend you upgrade to Appweb 4 and Ejscript 2. Much more flexible.