我正在使用这个 jQuery ajaxForm 插件将文件上传到我的服务器,并显示文件上传的进度(因为它主要用于视频上传)。我已经让这一切都按照我想要的方式正常工作,但是我不知道如何实现我想要做的事情。
所以我想要做的是:
- 提交表单 - 在数据库中创建新行
- 从中返回 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
}
});