I use Valums AjaxUpload for uploading file in my ASP.NET MVC 3 application .
new AjaxUpload($('input.partupload'), {
autoSubmit: true,
action: '/AdminPanel/Car/UploadPart',
onSubmit: function (file, ext) {
if (!(ext && /^(zip)$/.test(ext.toLowerCase())))
{
$('#hinf').fadeIn('slow');
$('#hinf').html("Please, upload only Zip files!!");
return false;
}
},
data: { path: directoryPath,parentName : part, carId: @Model.carID, color: color },
onComplete: function (file,response) {
var model = file.replace('.zip','');
if(response=="true")
{
alert(response);
createTree(part, model + '*' + part);
}
else
{
alert(response);
alert("Error during process");
}
}
});
In my controller I have
HttpPostedFileBase file = Request.Files[0];
if (...)
{
//Here my alert fires and onComplete is OK
return Content("true");
}
else
{
//FAIL!!! Nothing is happened in OnComplete!!!!!!
return Content("false");
}
So, I don't understand what is difference to return "true" or "false"... Why I see result at first time, and don't see at second... Need in your help))))
Huh, I figure out this... Problem is that in ajaxupload.js something wrong with "false" value, so what neeeded is to change "false" to something other value!!!
So, it works perfectly!!!