FileUpload Error

Discussion in 'ASP.NET 2.0' started by Bruce, Feb 23, 2007.

  1. Bruce

    Bruce DiscountASP.NET Staff

    I think you need to supply a physical path when using a saveas method.


    Try
    tring savePath = Server.MapPath("/images");

    I assume the images directory is under your website root.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  2. Thank you very much
     
  3. Server Error in '/' Application.


    The SaveAs method is configured to require a rooted path, and the path '../images/a3.gif' is not rooted.
    But folder exsist and all permision open

    code




    string savePath = @"../images/";





    if (FileUpload1.HasFile)


    {


    string fileName = Server.HtmlEncode(FileUpload1.FileName);





    string extension = System.IO.Path.GetExtension(fileName);


    if ((extension == ".gif") | (extension == ".jpg") | (extension==".jpeg"))


    {


    savePath += fileName;


    FileUpload1.SaveAs(savePath);


    }
     

Share This Page