提交表单时,保管箱选择器的值在服务器上是一个空字符串。所有其他输入的值在服务器上显示良好。此外,当为 Dropbox 选择器触发成功事件时,正确的链接会出现在alert
.
为什么链接没有到达后端?
这是我在 Jade 中的客户端代码:
extends layout
block styles
block content
.container
div#alertStage
form#shareForm.form-horizontal(method='post', action='/share', enctype='multipart/form-data')
.control-group
input(type='text', placeholder='enter class code', name='classCode', required='required')
.control-group
input(type='text', placeholder='enter professor', name='professor', required='required')
.control-group
textarea(rows='3', placeholder='enter description', name='description', required='required')
.control-group
input#db-chooser(type='dropbox-chooser', name='dropboxLink', style='visibility: hidden', data-link-type='preview')
.control-group
input#shareSubmit.btn-primary(type='submit', value='Upload')
block scripts
script(src='https://www.dropbox.com/static/api/1/dropbox.js', id='dropboxjs', data-app-key='kkobu9cjygmh6js')
script
$(document).ready(function()
{
$('#shareSubmit').on('click', function(e)
{
var message = '';
e.preventDefault();
//TODO: Validate data
$('#shareForm').submit();
});
document.getElementById("db-chooser").addEventListener("DbxChooserSuccess", function(e)
{
alert("Here's the chosen file: " + e.files[0].link)
}, false);
});