tags:

views:

37

answers:

3

i want to ask how to upload my files outside the server (for security issue) i use teleric Rad UploadFiles (ASP.net web application)..the problem that i cannot specify the required path outside the server using the method

server.map("~\..\") to go outside the server i get this

exception Cannot use a leading .. to exit above the top directory.

is there any way to determine a path outside the server

please help..

A: 

Use a full path, like "c:\uploads" and be sure that the web process has permission to write to that folder

Ray
but when the application published on the server , can the server identify an absolute path like this???
I do this with no problems on my servers. I suggest you store the path itself in the web.config file (appSettings section) so you can have different paths for dev and production servers.
Ray
thank u so much,i think this is the solution ,, please two questions(do u use Server.Map()function),,how to give the web process this permission
no need for Server.Map, since this path is outside your web site structure.Grant read, write, and modify rights on the folder to the user account under which your site runs (in IIS 6, right click on the site, select Directory Security, then look under Authentication and access control to see the anonymous user).
Ray
great ,, thank u so much for your detailed answer
A: 

I think you're running into a problem because of the server.map(..) call, can you not just use a hard coded path (read from config of course). So use something like "C:\UploadedFiles\" You'll need to make sure the user that ASP.NET is running under has the rights to write to that directory, etc.

Paul Hadfield
thank you so much please can you give me more details where in the config file and what is the alternative to Server.Map()and the repetitive question ::when the application published on the server , can the server identify an absolute path like this???
+1  A: 

This is fully covered in the Telerik documentation for this control which can be found here. In brief:

[ASP.NET] RadUpload declaration

<telerik:RadUpload ID="RadUpload1" Runat="server" />
<asp:Button Runat="server" ID="Button1" Text="Submit"
  OnClick="Button1_Click" />

[C#] Click event handler

using Telerik.Web.UI;
...
protected void Button1_Click(object sender, System.EventArgs e)
{
  foreach (UploadedFile f in RadUpload1.UploadedFiles)
  {
      f.SaveAs( "c:\\uploaded files\\" + f.GetName(), true);
  }
} 
Lazarus
but when the application published on the server , can the server identify an absolute path like this???
Of course, Server.MapPath just takes a path of the form "~/directory/directory/" and converts it to "C:\Inetapp\www\directory\directory".
Lazarus
thank you so much ,, but i don't know why my team leader tells me (don't use any absolute paths in your application as the server can't recognize them ,,he tells me to use Server.Map() instead but in this problem i wanna to upload outside the server and this method convert the path to be in the server)