Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string uploadPhoto(HttpPostedFile file, string folder)
- {
- string path = string.Empty;
- string pic = string.Empty;
- if (file != null)
- {
- pic = Path.GetFileName(file.FileName);
- path = Path.Combine(HttpContext.Current.Server.MapPath(folder), pic);
- file.SaveAs(path);
- using (MemoryStream ms = new MemoryStream())
- {
- file.InputStream.CopyTo(ms);
- byte[] array = ms.GetBuffer();
- }
- }
- return pic;
- }
- string pic = string.Empty;
- string folder = "~/Content/imagenes";
- if (view.imageFile != null)
- {
- pic = FilesHelpers.uploadPhoto(view.imageFile, folder);
- pic = string.Format("{0}/{1}", folder, pic);
- }
- var factura = toFactura(view);
- factura.foto = pic;
- db.factura.Add(factura);
- db.SaveChanges();
- return RedirectToAction("Index");
- }
- ViewBag.fichaCamion = new SelectList(db.camion, "id", "camion1", view.fichaCamion);
- ViewBag.cliente = new SelectList(db.cliente, "id", "compania", view.cliente1);
- return View(view);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement