Last active
August 29, 2015 14:21
-
-
Save Riduidel/d6bd93588a47f3bf000b to your computer and use it in GitHub Desktop.
Upload ajax vers Wisdom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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() | |
}); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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