3
我使用this jQuery ajaxForm plugin將文件上傳到我的服務器,並且還顯示文件上傳的進度(因爲它主要用於視頻上傳)。我已經得到了這一切的工作很好,我想如何,但我無法弄清楚如何實現我想要做的。jQuery ajaxForm插件 - 從beforeSend回調結果提交值
所以我希望能夠做的是這樣的:
- 提交表單 - 從在數據庫中創建新行
- 回報UNIQUEID並與文件提交上傳
我需要/想要這樣做的原因是因爲當某人上傳視頻時,我想讓他們填寫視頻詳情(視頻標題,說明等),並在視頻仍在上傳時保存這些視頻。所以爲此,我需要在數據庫中創建一行,以便創建該視頻的唯一ID,然後將該值返回到視頻上傳本身,以便可以使用視頻上傳詳細信息修改該行,並使用該唯一ID當用戶保存視頻信息時,它知道將要播放哪個視頻。
$('.upload-page form.video-upload').ajaxForm({
url: "ajax/upload.php",
data: {videoID: "videoID"}, //would I be able to modify this from beforeSend?
beforeSend: function() {
//This would be where I would make an ajax call to create the row in the database
//then i would need to return the value from here to the upload form somehow?
},
uploadProgress: function(event, position, total, percentComplete) {
//returns back video upload progress
},
complete: function(xhr) {
//Upload complete
}
});