locked
WebImage Upload problem RRS feed

  • Question

  • User-770252936 posted

    I'm trying to do with the image upload WebImage

            WebImage photo = null;
            
            var fDurum = Request.Form["fDurum"];
            var fBaslik = Request.Form["fBaslik"];
            var fGrafik = Request.Form["fGrafik"];
            var fSira = Request.Form["fSira"].AsInt(99);
            
            if (IsPost)
            {
                photo = WebImage.GetImageFromRequest();
                
                if (fBaslik.Trim().IsEmpty())
                {
                    ModelState.AddError("fBaslik", "Başlık giriniz");
                }
                else if (photo == null)
                {
                    ModelState.AddErro("fGrafik", "Banner grafiği seçiniz");
                }
    
                
                if (ModelState.IsValid)
                {
                    var ad = DateTime.Now.ToString().Replace(".", "").Replace(" ", "").Replace(":", "");
                    var tip = Path.GetExtension(photo.FileName);
                    var ImagePath = "../Images/Banner/" + ad + tip;
    
                    photo.Resize(670, 260, preserveAspectRatio: false, preventEnlarge: false);
                    photo.Save(ImagePath);
                    
                    var db = Database.Open("SQLconn");
                    var InsertSql = "INSERT INTO Haberler (Durum, Baslik, Banner, Sira) VALUES (@0, @1, @2, @3)";
                    db.Execute(InsertSql, fDurum, fBaslik, ImagePath, fSira);
                }

     

    Even though I select photos, photo objects constantly coming null ???

    Friday, May 9, 2014 8:35 AM

Answers

  • User-821857111 posted

    Where is the markup for your form? Does it include the enctype="multipart/form-data" attribute?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 9, 2014 8:56 AM