Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America

asked on 

aspx error

Request.Files[fileName] has alert about implicit. Do you know how to fix it?
protected void Page_Load(object sender, EventArgs e)
    {
        foreach (string fileName in Request.Files)
        {
            HttpPostedFileBase file = Request.Files[fileName];
            //Save file content goes here
            fName = file.FileName;
            if (file != null && file.ContentLength > 0)
            {
                var originalDirectory = new DirectoryInfo(string.Format("{0}Images\\fleets", Server.MapPath(@"\")));
                //string pathString = System.IO.Path.Combine(originalDirectory.ToString(), "imagepath");
                string pathString = originalDirectory.ToString();
                var fileName1 = Path.GetFileName(file.FileName);
                bool isExists = System.IO.Directory.Exists(pathString);
                if (!isExists)
                    System.IO.Directory.CreateDirectory(pathString);
                var path = string.Format("{0}\\{1}", pathString, file.FileName);
                file.SaveAs(path);
            }
        }


    }

Open in new window

ASP.NETC#

Avatar of undefined
Last Comment
Eduard Ghergu
ASKER CERTIFIED SOLUTION
Avatar of Eduard Ghergu
Eduard Ghergu
Flag of Romania image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of ITsolutionWizard

ASKER

That is what is showing only. Maybe u can put the codes on visual studio and see. It should be very straight forward
Avatar of Eduard Ghergu
Eduard Ghergu
Flag of Romania image

Hi,

Try with: HttpPostedFileBase file = (HttpPostedFileBase)Request.Files[fileName];
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo