File upload problem

File upload problem

am 11.04.2008 10:13:51 von Domac

Hi,

I want to upload *.jpg files to server using FileUpload control. Hosting is
shared and administrator informed me that I have to use medium trust level
to upload files. How to achieve that?

I get error:

: The application attempted to perform an operation not allowed by the
security policy. To grant this application the required permission please
contact your system administrator or change the application's trust level in
the configuration file.


Line 10: FileUpload1.SaveAs("\images\res\" & FileUpload1.FileName)I
am new to ASP.NET ?

Thanks a lot!
Domac

Re: File upload problem

am 11.04.2008 17:40:18 von pbromberg

You have to grant write permissions on the images folder to the ASPNET or
whatever account your app is running under.
Peter
"Domac" wrote in message
news:ewYRcO6mIHA.4196@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> I want to upload *.jpg files to server using FileUpload control. Hosting
> is shared and administrator informed me that I have to use medium trust
> level to upload files. How to achieve that?
>
> I get error:
>
> : The application attempted to perform an operation not allowed by the
> security policy. To grant this application the required permission please
> contact your system administrator or change the application's trust level
> in the configuration file.
>
>
> Line 10: FileUpload1.SaveAs("\images\res\" &
> FileUpload1.FileName)I am new to ASP.NET ?
>
> Thanks a lot!
> Domac
>

Re: File upload problem

am 12.04.2008 09:37:54 von lexa

On Apr 11, 10:13=A0am, "Domac" wrote:
> Hi,
>
> I want to upload *.jpg files to server using FileUpload control. Hosting i=
s
> shared and administrator informed me that I have to use medium trust level=

> to upload files. How to achieve that?
>
> I get error:
>
> : The application attempted to perform an operation not allowed by the
> security policy. =A0To grant this application the required permission plea=
se
> contact your system administrator or change the application's trust level =
in
> the configuration file.
>
> Line 10: =A0 =A0 =A0 =A0 FileUpload1.SaveAs("\images\res\" & FileUpload1.F=
ileName)I
> am new to ASP.NET ?
>
> Thanks a lot!
> Domac

MSDN: "For a call to the SaveAs to work, the ASP.NET application must
have write access to the directory on the server. There are two ways
that the application can get write access. You can explicitly grant
write access to the account under which the application is running, in
the directory in which the uploaded files will be saved.
Alternatively, you can increase the level of trust that is granted to
the ASP.NET application."

http://msdn2.microsoft.com/en-us/library/system.web.ui.webco ntrols.fileuploa=
d.saveas(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/wyts434y(VS.80).asp x

Hope this helps