tsaixingwei
unread,Feb 2, 2011, 12:59:51 AM2/2/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to MynaJS-General
In the documentation it was mentioned that the file upload information
would be available as
$req.data.parameter_name ={
diskItem: org.apache.commons.fileupload.disk.DiskFileItem,
stats:{
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 $req.data.parameter_name 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
<p>
File Input: <br>
<input type="file" name="fileupload1"><br/>
Some Json Code:<br>
<textarea cols="60" rows="10" name="json">
{
"array":[
"thing1",
"thing2"],
"number":12,
"string":"some string",
"sub_object":{
"number":12,
"string":"some string"
}
}
</textarea><p>
More Json Code with the same name:<br>
<textarea cols="60" rows="3" name="json">
{
"phrase":"Dude, where's my car?"
}
</textarea><p>
A Cross Site Scripting hack:<br>
<textarea name="xss">';alert(String.fromCharCode(88,83,83))//\';
alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//
\";
alert(String.fromCharCode(88,83,83))//--></SCRIPT>">'>
<SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT></textarea>
<p>
Display: <select name="dump_data">
<option value="filtered">$req.data</option>
<option value="raw">$req.rawData</option>
</select><p>
<button type="submit">submit</button>
</form>
<@if $req.data.dump_data == "filtered">
<%=Myna.dump($req.data,"$req.data", 6)%>
<@elseif $req.data.dump_data == "raw">
<%=Myna.dump($req.rawData,"$req.rawData", 6)%>
</@if>
<@if $req.data.fileupload1 != null>
Uploaded File:<br>
Type of fileupload1: <%= typeof $req.data.fileupload1 %> <br/>
<%=Myna.dump($req.data.fileupload1,"$req.data.fileupload1", 6)%>
</@if>