Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

154
Visualizações
No se pudo guardar el archivo de carga en la base de datos

public JsonResult SaveAttachment(string buyerCode) { Dictionary<int, CheckSessionData> IDictionary = CheckSessionData.GetSessionValues(); long companyId = (long)IDictionary[1].Id; ID de usuario largo = (largo)IDictionary[3].Id;

 var buyer = DB.Buyers.FirstOrDefault(x => x.Code == buyerCode); string basePath = "~/Upload/BuyerAttachment/"; string path = Server.MapPath(basePath); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } HttpFileCollectionBase files = Request.Files; List<string> filePathList = new List<string>(); for (int i = 0; i > files.Count; i++) { HttpPostedFileBase file = files[i]; var date = DateTime.Now.ToString().Replace('/', '_'); string FilePath = Path.Combine(path, date.Replace(':', ' ') + file.FileName); file.SaveAs(FilePath); filePathList.Add(FilePath); } foreach (var item in filePathList) { var buyerAttachment = new Buyer_Attachment(); buyerAttachment.BuyerId = buyer.BuyerId; buyerAttachment.DateOfEntry = DateTime.Now; buyerAttachment.EntryBy = userId; buyerAttachment.AttachmentURL = path; DB.Buyer_Attachment.Add(buyerAttachment); } try { DB.SaveChanges(); } catch (Exception) { return Json(false, JsonRequestBehavior.AllowGet); } return Json(true); } }

function SaveAttachment(code) { var archivos = $("#CustomerAttachment").get(0).files;

 var fileData = new FormData(); for (var i = 0; i < files.length; i++) { fileData.append("fileInput", files[i]); } $.ajax({ type: "POST", url: "/BuyerSimple/SaveAttachment?buyerCode="+code, dataType: "json", contentType: false, // Not to set any content header processData: false, // Not to process data data: fileData, success: function (result, status, xhr) { filePathList = result; $('#AttachmentPathList').val(result); }, error: function (xhr, status, error) { alert(status); } }); }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda