Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpPostedFileBase missing reference

I'm getting an error on HttpPostedFileBase:

The type or namespace name 'HttpPostedFileBase'could not be found(are you missing a using directive or an assembly reference?)

I have already tried to use using System.Web but didn't work at all.

Edit #1

public IActionResult Upload(HttpPostedFileBase file)
    {

        if (file.contentlength > 0)
        {
            var filename = Path.GetFileName(file.filename);
            var path = Path.Combine(Server.mappath("~/app_data/uploads"), filename);
            file.saveas(path);
        }

        return RedirectToAction("index");
    }

I dont acctually have a reference folder No references folder

like image 745
Dorin Munteanu Avatar asked Dec 18 '22 22:12

Dorin Munteanu


1 Answers

You can't mix and match tutorials and framework versions. You're on ASP.NET Core 2.0.8, which doesn't contain HttpPostedFileBase.

The ASP.NET Core counterpart of HttpPostedFileBase is IFormFile.

like image 193
CodeCaster Avatar answered Dec 20 '22 12:12

CodeCaster