Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in my application uploading excel and insertion values into database working properly but when I published in iis server then in local link when uploading excel then showing this error "Access to the path .xlxs is denied".
Posted

Check your paths: it worked in development because the Server and the Client were the same computer, and your web app had access to the whole computer that your client did.

In production, you are restricted to (pretty much) only the folders below your website home folder - so if you try to access anything outside that, it will fail.

Sorry, but without the relevant code fragments we can't be at all specific.
 
Share this answer
 
Comments
Asma Siddiqua 18-Jun-15 5:50am    
if (FileUpload1.HasFile)
{
string excelPath = Server.MapPath("~/Uploads/") + Path.GetFileName(FileUpload1.PostedFile.FileName);
FileUpload1.SaveAs(excelPath);
ImporttoSQL(excelPath);
}
like this i did
OriginalGriff 18-Jun-15 6:03am    
So where does the error occur?
Two places:
1) FileUpload1.SaveAs - in which case you need to check the access permissions on your production folder "Uploads". Chances are they are set to read only, which would be pretty normal. (This would work in development, as no special permissions would be applied to the folder on your own machine)
2) InporttoSQL - in which case you need to look at exactly what that method is doing.
OriginalGriff 18-Jun-15 6:05am    
BTW: It's probably not a good idea for a website to store files under the user-supplied name: there is a very good chance that two different users will pick the same name!
I use GUIDs for the file name, and cross reference the user name and user to the GUID in the database.
Asma Siddiqua 18-Jun-15 8:37am    
I want to upload excel and store those values into database then how to do it in ur way?
Check that you're saving to a valid path on the server and that the account your code is running under (probably anonymous user) has write access to that path. It's usual for the code to only have read access, you might need to configure your server to allow write access.
 
Share this answer
 
Comments
Asma Siddiqua 18-Jun-15 5:22am    
yes i saving valid path and i ddnt give any authentication for allowing any users..whn before I was published it was worked properly but coz of some issue i updated and published again then showing this error.
F-ES Sitecore 18-Jun-15 5:24am    
If you're always saving the file to the same location then something else to check if that you are closing anything that access that file, as it could be left locked by a previous request. ie make sure you are calling Dispose and\or Close on any streams\ connections etc that access the file.
Asma Siddiqua 19-Jun-15 3:03am    
one thing I am using uploads folder for download and upload my data by excel in some methode so when i click download button then its getting download but when clicking upload then showing above error.

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