0
我是新來的Grails框架,我堅持了以下問題:如何Grails的異步上傳文件3
- 我想與文件上傳項目和標題,說明一些細節,我有很大stl 3d文件。雖然文件上傳需要時間,我希望用戶在下一頁上,並填寫項目休息的詳細信息,如標題說明等。
我無法弄清楚,我將如何做到這一點..我看看grails aynch編程,但我無法弄清楚如何實現。
,如果有人對這個
我是新來的Grails框架,我堅持了以下問題:如何Grails的異步上傳文件3
我無法弄清楚,我將如何做到這一點..我看看grails aynch編程,但我無法弄清楚如何實現。
,如果有人對這個
我對包括文件上傳,這是我想被異步完成一個形式,而回工作指導,我會很感激。它花了很多谷歌搜索,不幸的是我不記得我用過的任何引用,但這是我最終做的。
我在文件輸入中包含了一個onchange屬性,當選擇一個文件時,會調用一個javascript函數來異步驗證和上傳文件。
文件輸入:
<input type="file" name="uploadMedical" id="uploadMedical" onchange="validateAndUpload(this, $(this));" accept=".pdf,.jpg,.jpeg" multiple>
中的JavaScript (我盡我所能去帶出代碼是不相關的問題,同時仍留有足夠幫助解決你的問題):
function validateAndUpload(input, documentInput){
var uploadForm = $("#uploadForm");
// Stop the browser from submitting the form.
uploadForm.submit(function(event) {
event.preventDefault();
});
// Get the selected files from the input.
var files = input.files;
// Create a new FormData object.
var formData = new FormData();
// Loop through each of the selected files.
for (var ii = 0; ii < files.length; ii++) {
var file = files[ii];
// Add the file to the request.
formData.append('supportingDocumentation', file, file.name);
}
//Include ID of record to associate this upload with
formData.append('id', getAppealId());
// Submit the form using AJAX.
$.ajax({
type: 'POST',
dataType : "html",
url: url_str,
data: formData,
processData: false,
contentType: false,
beforeSend:function(){
//indicate that the file is uploading
},
success:function(htmlData){
//display the new list of files on the page
},
error:function(ee){
//indicate that the upload failed
},
complete:function(){
//reset the file input so more files can be uploaded
}
})
}
Grails在這個主題上的指南沒有幫助(http://guides.grails.org/grails-upload-file/guide/index.html) – npskirk
感謝npskirk這個鏈接,但是我正在尋找文件的異步上傳 – rupi
這是我如何實現異步hronous: 高清答應= {project.async.task withTransaction {// 長在這裏的任務運行 回報 「成功」 }} promise.onError {Throwable的錯誤 - > 的println「發生錯誤$ {犯錯.message}「 } promise.onComplete {result - > println」任務完成$ {result}「 } – rupi