File Upload information in $

Skip to first unread message


Feb 2, 2011, 12:59:51 AM2/2/11
to MynaJS-General
In the documentation it was mentioned that the file upload information
would be available as

$ ={
diskItem: org.apache.commons.fileupload.disk.DiskFileItem,
fieldName:String, name of field in form,
fileName:String, name of file on client side,
contentType:String, mime type,
isInMemory:boolean, true if file contents are in memory,
sizeInBytes:int, size in bytes,
diskLocation:String, the current location of the uploaded file

However, in a simple test, the $ returns not an
object structure like the above but instead it returns just a simple
string which is the fileName. So am I doing it right or is the above
object structure not implemented yet?

My test code is one of the examples provided in the documentation but
modified to contain a file input html element:

<form method="post">
First Name: <input name="first_name"><br>
Favorite colors:<br>
<input type="checkbox" name="favorite_colors" value="red">Red
<input type="checkbox" name="favorite_colors" value="orange">Orange
<input type="checkbox" name="favorite_colors" value="yellow">Yellow
<input type="checkbox" name="favorite_colors" value="green">Green
<input type="checkbox" name="favorite_colors" value="blue">Blue
<input type="checkbox" name="favorite_colors" value="indigo">Indigo
<input type="checkbox" name="favorite_colors" value="violet">Violet

File Input: <br>
<input type="file" name="fileupload1"><br/>

Some Json Code:<br>
<textarea cols="60" rows="10" name="json">
"string":"some string",
"string":"some string"

More Json Code with the same name:<br>
<textarea cols="60" rows="3" name="json">
"phrase":"Dude, where's my car?"

A Cross Site Scripting hack:<br>
<textarea name="xss">';alert(String.fromCharCode(88,83,83))//\';

Display: <select name="dump_data">
<option value="filtered">$</option>
<option value="raw">$req.rawData</option>
<button type="submit">submit</button>

<@if $ == "filtered">
<%=Myna.dump($,"$", 6)%>
<@elseif $ == "raw">
<%=Myna.dump($req.rawData,"$req.rawData", 6)%>

<@if $ != null>
Uploaded File:<br>
Type of fileupload1: <%= typeof $ %> <br/>
<%=Myna.dump($,"$", 6)%>


Feb 2, 2011, 12:59:52 AM2/2/11
to MynaJS-General

Mark Porter

Feb 2, 2011, 10:23:35 AM2/2/11
This is because the form tag requires an [ enctype="multipart/form-data" ] when uploading files. This is not a Myna requirement but rather an HTML requirement. 

Have a look in the /examples/index.ejs folder, particularly the "File Uploads" example for a demo of multiple file uploads with progress output

Mark Porter

Myna JavaScript Application Server
Easy web development with server-side JavaScript

You received this message because you are subscribed to the Google Groups "MynaJS-General" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply all
Reply to author
0 new messages