Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In my application I am using the document upload. I will paste my whole application in the server, there is the folder named as attach document. When I click the upload button the file will be stored in that folder. it is working fine in local system, but it is not working for that server system it gives the logon failure message. I am using the server.mappath(~/attach document) function for getting the location but it gives that error. Can anyone help me to solve this problem.

Thanks in Advance
Posted
Updated 6-Dec-11 18:52pm
v2
Comments
[no name] 7-Dec-11 1:03am    
EDIT: added code block

Try
Uploading files to a web server [^]

ServerSavePath := Server.MapPath('/Upload');


This will return the physical path for a given virtual path. If your web application's root is under 'c:\InetPub\WWWRoot\MyWebApplication' then Server.MapPath('/Upload') would return 'c:\InetPub\WWWRoot\MyWebApplication\Upload'.
 
Share this answer
 
Comments
Monjurul Habib 7-Dec-11 3:19am    
nice link, 5!
RaviRanjanKr 7-Dec-11 3:24am    
Thanks :)
Hi,

Thanks for the reply I given this but it gives the error as "The SaveAs method is configured to require a rooted path, and the path '~/AttachDocument/ger.txt' is not rooted."
Here is the code:

string fileLocation = @"~/AttachDocument/";


Thanks
 
Share this answer
 
v3
Comments
Monjurul Habib 7-Dec-11 3:23am    
5! for self solution.
i think you don't have a permission for that try to set the permission first.

thanks
 
Share this answer
 
You should be check the permission for your folder setting.
You can refer this url...................http://support.microsoft.com/kb/308419[^]
 
Share this answer
 
You can use this to store file in particular folder :

C#
string fileName = string.Empty;

if (txtImage.HasFile && var == true)
{
fileName = @"~\UsersFile\" + txtImage.FileName.ToString();
txtImage.SaveAs(Server.MapPath("~/UsersFile/") + txtImage.FileName.ToString());
}
 
Share this answer
 
Don't forget to add

<identity impersonate="true"/>


in your web.config file.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900