我认为有一些非常简单的事情我看不到这里是错误的。这是我上传文件的jquery代码:
import: function (e) {
e.preventDefault();
var formData = new FormData();
jQuery.each($('#import_excel_file')[0].files, function(i, file) {
formData.append('import_file', file, 'xls');
});
formData.append('fuel_type_id', $('#import_fuel_type').val());
this.shipOff(formData);
},
shipOff: function (formData) {
$.ajax({
type: 'POST',
url: App.Options.rootUrl + "/stations/stations/excel_import",
data: formData,
cache: false,
contentType: false,
processData: false,
success: function (data) {
console.log('successful upload', data);
}
});
}
然后在我调用的控制器中import = Excel.new(xls_file.tempfile.to_path.to_s)
,我收到一个错误,例如TypeError (/var/folders/rd/58f3hjw10lv09q_8hsl0l7zn1mn1rf/T/RackMultipart20130909-36782-r1bv5n is not an Excel file)
我在这里想念什么?