upload file permission

Discussion in 'Knowledge Base' started by babs_speed, Oct 13, 2009.

  1. babs_speed

    babs_speed Guppy

    i get error everytime i try upload file with asp.net

    Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    if (FileUpload1.HasFile)
    FileUpload1.SaveAs( "\\Images\\" + FileUpload1.FileName);
    Label1.Text = "success";
    Label1.Text = "fail";

    i have tryed this threads "http://support.jodohost.com/showthread.php?t=7974" for using medium trust but its not work for me..

    i need help...
  2. equanimity

    equanimity Perch

    You need phisical path in SaveAs sentence.

    Try this:

    FileUpload1.SaveAs( Server.MapPath("\\Images\\" + FileUpload1.FileName));
  3. babs_speed

    babs_speed Guppy

    i have tried that code.. i using sever h-spare, for server h-spare if i using sever.mappath / Request.PhysicalApplicationPath the path will be deny...

    that's why i can't using that code

    i don't know what i have to do..
  4. Stephen

    Stephen US Operations Staff Member

    Please download the medium trust config file here:

    once you have done that set your asp.net 2 config to use this (from the web.config set mediumtrust.config to the the medium trust, and set trust level to medium, and set override to false)

    there are a few mods to this medium trust since it was updated last here, but mostly LINQ, and Email settings, I will work to get it updated in the next week, but it won't have any bearing on your upload issue.

    you can test your code in your desktop environment after this

Share This Page

JodoHost - 26,000 hosting end-users in 100 countries
Plesk Web Hosting
VPS Hosting
H-Sphere Web Hosting
Other Services