5
Tôi hiện đang làm hướng dẫn sau đây để xử lý tải lên hình ảnh từ điều khiển mùa hè trong ASP.NET MVC Razor.Tải tệp Summernote lên máy chủ
đang Server:
[HttpPost]
public ActionResult UploadImage(HttpPostedFileBase file)
{
var imageUrl = UpdateProfilePicture(file);
return Json(imageUrl);
}
Và Khách hàng bên ajax:
<script>
$('.summernote').summernote({
height: 200,
focus: true, onImageUpload: function (files, editor, welEditable) {
sendFile(files[0], editor, welEditable);
}
});
function sendFile(file, editor, welEditable) {
console.log(file);
$.ajax({
data: {file:file},
type: "POST",
url: "@Url.Action("UploadImage","Message")",
cache: false,
contentType: false,
processData: false,
success: function (url) {
editor.insertImage(welEditable, url);
}
});
}
tôi có kết quả ở phương pháp phía máy chủ một, nhưng thông số HttpPostedFileBase file
là null
một số ví dụ nói rằng hoạt động, nhưng mã của tôi không hoạt động chức năng!
Bất kỳ ý tưởng nào?
Bạn có quản lý để sửa chữa nó? – Stefanvds
Điều gì sẽ xảy ra với giao diện console.log (tệp) của bạn? Tôi nghĩ rằng giá trị đó không thể được dịch chính xác thành HttpPostedFileBase –