我有一个动态生成的表是可编辑的。单击表中的任何单元格,我都可以更改其文本。你知道吗
在一列中显示一个图像。当用户单击它时,我将该列的html更改为<input type='file'>
,并触发一次单击,从而使用户选择一个文件作为图标上传。你知道吗
在表的最后一列中,我有一个commit按钮。如果用户做了一些更改并按了commit,我必须选择整行(一些文本字段和一个文件字段),将所有内容添加到表单中,包括用户选择的文件,并将其发送到python脚本以将其上载到s3服务器。你知道吗
我的问题是:如何发送此表格?你知道吗
我目前正在使用这个脚本,但它不起作用,因为它只发送文本,因为python(django)脚本端的request.Files
结果是空的。你知道吗
function update(a) {
try {
var button = $(a);
var row = $(button.parent());
var rowcount = button.parent().parent().parent().children().index(button.parent().parent());
var filerow = '';
var formrow = new Array();
var rowkey = new Array('Topic', 'TopicDescription');
var cnt = 0;
var form = $('#dyno_form');
row.siblings().each(function () {
if ($(this).find($('input:file')).length > 0) {
$(this).find($('input:file')).appendTo($(form));
} else if ($(this).find($('img')).length == 0) {
formrow[cnt++] = '<input type="text" value="' + $(this).html() + '" name="' + rowkey[cnt - 1] + '"/>';
}
});
$(form).append(formrow[0]);
$(form).append(formrow[1]);
$(form).submit();
} catch (a) {
alert(a);
}
}
下面是HTML:
<form id='dyno_form' action='' method="post" style="visibility:hidden">{% csrf_token %}</form>
我该怎么做呢?你知道吗
当您想要上传一个文件时,
form
元素需要有正确的enctype
属性,并且方法必须是post
。你知道吗否则,将只上载输入的值。你知道吗
相关问题 更多 >
编程相关推荐