Hi,
When I try to upload an image I get the filename as a string instead
of the file's content. I followed a few Dojo samples successfully, so
I wonder if TG strips the file content somewhere along the way.
The form is:
<form id="uploadForm" method="post" action="upload"
enctype="enctype="multipart/form-data">
<input type="file" name="image" value="">
<input type="button" id="uploadButton" value="Submit" />
</form>
The upload button is hooked up to an uploadImage() function:
var uploadButton = dojo.byId('uploadButton');
dojo.connect(uploadButton, 'onclick', 'uploadImage');
The uploadImage() function uses dojo.io.iframe.send (the only way to
upload a file) because xhrPost(0 can't upload files.
function uploadImage()
{
upload_url ="
http://localhost:8080/upload_image";
var request = {
url: upload_url,
method: 'POST',
form: "uploadForm",
load: function(response, ioArgs)
{
console.log('success');
},
error: function(error)
{
console.log('failure');
},
};
// Must use io.iframe.send() to send files
dojo.io.iframe.send(request);
//dojo.xhrPost(request);
}
Here is my controller:
@expose()
def upload_image(self, **kw):
image = kw['image']
...
The image I get is just the filename I selected in the form.
Thanks, Carl