Anyname Donotcare
Anyname Donotcare

Reputation: 11423

how to upload a file outside the server asp.net

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..

Upvotes: 1

Views: 7840

Answers (4)

APetersen786
APetersen786

Reputation: 1

I am using Internet Explorer 8, and had similar issues. I could upload from the server the upload page is hosted on, in IIS7. I could also upload from another different server but on the same domain as the webserver (that hosted the upload page). Both these worked.

But the upload from a PC that was not on the domain, did not upload, and gave the 500 error. I finally added the upload site on internet explorer to the Trusted Sites, and it worked fine. :)

Before that I checked rights on folders etc, and that was all ok. Also had size issues, then got a blog that said I should add:

<requestLimits maxAllowedContentLength="2000000000" /> <!-- bytes -->
</requestFiltering>

to the applicationHost.config file on the webserver in location C:\windows\system32\inetsrv\config\

In addition in IIS7 I also had to check the asp properties in server manager for the website that the upload page is on, changed the Limit Properties \ Maximum Requesting Entity Body Limit to match the size in the applicationHost.config file.

This is a classic asp website.

Upvotes: 0

Lazarus
Lazarus

Reputation: 43094

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);
  }
} 

Upvotes: 1

Paul Hadfield
Paul Hadfield

Reputation: 6136

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.

Upvotes: 0

Ray
Ray

Reputation: 21905

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

Upvotes: 3

Related Questions