Skip to content

Instantly share code, notes, and snippets.

@Riduidel
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Riduidel/d6bd93588a47f3bf000b to your computer and use it in GitHub Desktop.
Save Riduidel/d6bd93588a47f3bf000b to your computer and use it in GitHub Desktop.
Upload ajax vers Wisdom
<div class="col-xs-9">
<form enctype="multipart/form-data" id="fileInputForm" method="POST" action="config//upload">
<input type="file" class="filestyle" id="fileInputChooser" value="">
</form>
</div>
/**
* Upload file for a page where source is set to file.
* This upload uses the form, and ajax coming from http://stackoverflow.com/a/8758614/15619
* to have that upload working.
* TODO check support on all browser
*/
uploadFileFor : function(page) {
var ppc = this
var form = $('#fileInputForm')[0]
var formData = new FormData(form);
$.ajax({
url: 'config/'+page.id+'/upload',
type: 'POST',
// Form data
data: formData,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
}).always(function(bytesSent) {
ppc.loadPages()
});
},
@Route(method = HttpMethod.POST, uri = "/{portal}/config/{page}/upload")
public Result uploadFileFor(@Parameter("portal") String portalId,
@Parameter("page") String pageId,
@FormParameter("fileInputChooser") FileItem uploaded) throws IOException {
// Et là, pas la peine de voir le code : uploaded est null !
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment