hep null, İşte benim GörünümDosya Yükleme ben isterlerse kullanıcı profili orada düzenlemek ve bir resim yüklenecek bir form oluşturmak istedik
// Form dize olduğunu @using(Html.BeginForm("EditProfile","Employee",FormMethod.Post, new { enctype = "multipart/form-data " }))
// Girdi HTML <input type="file" name="file" id="file"/>
// My Denetleyici Şimdi <input type="submit" name="SubmitBtn" value="SaveProfile" /> <input type="submit" name="SubmitBtn" value="Cancel" />
Gönder
//Profile Modification
[Authorize]
[HttpPost]
public ActionResult EditProfile(employer model, string SubmitBtn,HttpFileCollection file)
{
switch (SubmitBtn)
{
case "SaveProfile":
try
{
if (ModelState.IsValid)
{
//the file is always null
if (file != null)
{
//Function I want to Apply on file
model.logoname = logouploded(file);
return RedirectToAction("Profile", "Employer");
}
return RedirectToAction("EditProfile");
}
//ChangeEmployeeProfile(model);
}
catch (Exception ex)
{
ViewBag.warn = ex.Message;
return View(model);
}
break;
case "Cancel":
return RedirectToAction("index");
}
return View(model);
}
Şimdi olursa olsun dosyası her zaman Eylem Fonksiyonu parametre hala dosya boş olduğu gibi aynı zamanda HttpFileCollectionBase denedi boş geliyor yüklemek hangi dosya
Sadece Çalışan Modeli sadece resim dosya adını içerdiğinden söz Sadece Resim adını veritabanına kaydetmek istiyorum.
Merhaba, Geri gönderildikten sonra 'Request.Files 'koleksiyonunu kontrol ettiniz mi? –
"multipart/form-data" içindeki son boşluğu silin. doğru: "multipart/form-data" içindeki boşlukları düzelttikten sonra "multipart/form-data" –