我试图将对象列表从我的视图发送到控制器。每个对象都有一个文件以及其他一些属性。 这是模型:
public class FilesUploadModel
{
public HttpPostedFileBase file { get; set; }
public string fileTaskId { get; set; }
public bool upload { get; set; }
public bool read { get; set; }
public bool import { get; set; }
public bool isReupload { get; set; }
public int fileReadId { get; set; }
}
控制器:
public ActionResult FileSave(List<FilesUploadModel> models)
{}
这就是我试图将列表发送到控制器的方式:
var filesUploadModel = [];
function someFn(){
var uploadModel = {
file = someInput.files[0]
fileTaskId: "2563",
upload: true,
read: true,
import: true,
isReupload: false,
fileReadId: 0
}
filesUploadModel.push(uploadModel);
}
function UploadFiles(){
var formData = new FormData();
filesUploadModel.forEach(function (model) { //filesUploadModel is the list
formData.append('models', model);
});
$.ajax({
url: "/Company/FileSave",
type: 'POST',
enctype: 'multipart/form-data',
processData: false,
contentType: false,
data: formData,
complete: function (data) {
}
});
}
但是我无法在控制器中接收数据。无法在此处找到问题。
答案 0 :(得分:0)
您不是要发送文件列表,而是要发送带有文件列表的对象,请更改操作以接收具有文件列表属性的对象
image_input = Input((input_size, input_size, 3))
conv_0 = Conv2D(32, (3, 3), padding='SAME')(image_input)
conv_0_bn = BatchNormalization()(conv_0)
conv_0_act = Activation('relu')(conv_0_bn)
conv_0_pool = MaxPool2D((2, 2))(conv_0_act)
conv_1 = Conv2D(64, (3, 3), padding='SAME')(conv_0_pool)
conv_1_bn = BatchNormalization()(conv_1)
conv_1_act = Activation('relu')(conv_1_bn)
conv_1_pool = MaxPool2D((2, 2))(conv_1_act)
conv_2 = Conv2D(64, (3, 3), padding='SAME')(conv_1_pool)
conv_2_bn = BatchNormalization()(conv_2)
conv_2_act = Activation('relu')(conv_2_bn)
conv_2_pool = MaxPool2D((2, 2))(conv_2_act)
conv_3 = Conv2D(128, (3, 3), padding='SAME')(conv_2_pool)
conv_3_bn = BatchNormalization()(conv_3)
conv_3_act = Activation('relu')(conv_3_bn)
conv_4 = Conv2D(128, (3, 3), padding='SAME')(conv_3_act)
conv_4_bn = BatchNormalization()(conv_4)
conv_4_act = Activation('relu')(conv_4_bn)
conv_4_pool = MaxPool2D((2, 2))(conv_4_act)
conv_5 = Conv2D(128, (3, 3), padding='SAME')(conv_4_pool)
conv_5_bn = BatchNormalization()(conv_5)
conv_5_act = Activation('relu')(conv_5_bn)
conv_6 = Conv2D(128, (3, 3), padding='SAME')(conv_5_act)
conv_6_bn = BatchNormalization()(conv_6)
conv_6_act = Activation('relu')(conv_6_bn)
flat = Flatten()(conv_6_act)
fc_0 = Dense(64, activation='relu')(flat)
fc_0_bn = BatchNormalization()(fc_0)
fc_1 = Dense(32, activation='relu')(fc_0_bn)
fc_1_drop = Dropout(0.5)(fc_1)
output = Dense(2, activation='softmax')(fc_1_drop)
model = models.Model(inputs=image_input, outputs=output)
答案 1 :(得分:0)
我终于找到了问题。在尝试传递对象集合时,我们需要为每个对象添加一个索引:
library(survey)
my_survey <- svydesign(ids= ~1, strata = ~country, wts = ~wts, data = your_data)
# Then you can use the survey glm to do what you want via
svy_fit <- svy_glm(ethnic ~ elec_prox +
elec_comp + round + country, data = my_survey, family = binomial())