Jquery 如何将图像或文件发送到服务器?
你好我的朋友我的英语不好我希望你能理解我 我得到了图像路径和文件名,并在页面上显示了图片 但是如何将图像或文件发送到服务器? 谢谢您 当我点击按钮时,将图像或文件发送到服务器?ü html } 多谢各位Jquery 如何将图像或文件发送到服务器?,jquery,asp.net-mvc,c#-4.0,Jquery,Asp.net Mvc,C# 4.0,你好我的朋友我的英语不好我希望你能理解我 我得到了图像路径和文件名,并在页面上显示了图片 但是如何将图像或文件发送到服务器? 谢谢您 当我点击按钮时,将图像或文件发送到服务器?ü html } 多谢各位 $('#fileUpload').on('change', function (e) { temp = $(this).val().split('.').pop().toLowerCase(); path = $(this).val(); if (jQuery.inA
$('#fileUpload').on('change', function (e) {
temp = $(this).val().split('.').pop().toLowerCase();
path = $(this).val();
if (jQuery.inArray(temp, ['gif', 'png', 'jpg', 'jpeg']) == -1) {
resetFormElement(jQuery(this));
window.alert('Not an image!');
} else {
files = jQuery('#fileUpload').prop("files")[0];
blobURL = window.URL.createObjectURL(files);
$('#Crew_preview img').attr('src', blobURL);
$('#Crew_preview').slideDown();
$(this).slideUp();
e.preventDefault();
e.stopPropagation();
}
project
models
css
files
images
tempImages
是否在表单中指定enctype属性?“enctype=“multipart/form data”'您好,我没有使用enctype=“multipart/form data”,但现在我将尝试引用:我将研究感谢的问题
function AjaxForm(form, action) {
temp = $("form").serializeArray();
var SendData = new Object();
for (var i = 0; i < temp.length; i++) {
name = temp[i].name;
value = temp[i].value;
SendData[name] = value;
}
AddCrew(SendData);
function AddCrew(addData) {
addData["CompetencyID"] = addData["Competency"];
delete addData.Competency;
$.ajax(
{
url: 'Crew/AddCrew',
type: 'POST',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify({ incomingData: addData }),
success: function (Id) {
if (isGuidEmpty(Id)) {
alertify.alert("Crew was successfully added..");
$("#CrewGrid").jqxGrid('clear');
CrewGridFocus(Id); // crew.js create olan datayı gride bind eder
}
else {
alertify.error("a problem has occurred, try again later");
}
},
error: function (jqXHR, textStatus, errorThrown) {
alertify.alert("AddContract function error");
}
});
$('#fileUpload').on('change', function (e) {
temp = $(this).val().split('.').pop().toLowerCase();
path = $(this).val();
if (jQuery.inArray(temp, ['gif', 'png', 'jpg', 'jpeg']) == -1) {
resetFormElement(jQuery(this));
window.alert('Not an image!');
} else {
files = jQuery('#fileUpload').prop("files")[0];
blobURL = window.URL.createObjectURL(files);
$('#Crew_preview img').attr('src', blobURL);
$('#Crew_preview').slideDown();
$(this).slideUp();
e.preventDefault();
e.stopPropagation();
}
project
models
css
files
images
tempImages