Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi experts
i need to upload large file in my website ( < 200 MB ).
i changed my web config:

C#
<system.web>
     <httpRuntime maxRequestLength="200000" executionTimeout="3600"requestValidationMode="2.0"/>

......
</system.web>


and

C#
<system.webServer>
   <security>
       <requestFiltering>
           <requestLimits maxAllowedContentLength="200000000"/>
        </requestFiltering>
   </security>
</system.webServer>


in local host it is correct but in server i got this error:

404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

thanks in advance
Posted
Comments
Joezer BH 21-Aug-13 4:30am    
It does not look like size issues.
Looks more like path issues, try to post code and the values of the relevant Path variables
Dholakiya Ankit 22-Aug-13 6:39am    
yes me too check on server that folder which you are existing have read/write permissions and exists also?

I agree with Maimonides, it's related to path issues because of the error message which you got.

First, try to upload a small textfile(5 or 10 kb), if it fails then path is issue. Without seeing your code, I can't tell you more.

Here some fix links for you

Large file uploads in ASP.NET[^]
How to upload large size file/blob to azure storage using ASP.Net,C#[^]
Dealing With the ASP.Net Upload File Size Problem[^]
 
Share this answer
 
Comments
Joezer BH 22-Aug-13 6:48am    
5ed!
If the same code works on local but doesn't work on hosting server, then its not the issue with the code. Just check the configuration; especially the path of the file. May be you are giving the absolute path of the file to be uploaded and that path is not existing. The error you have mentioned refers to the issue of path.
 
Share this answer
 
its my code:

C#
if (oHttpPostedFile.ContentLength == 0)
                            {
                                //Your picture file was not successfully uploaded!
                                throw (new            MyWebApplication.ApplicationException(Resources.Messages.ErrorMessage010));
                            }
                            else
                            {
                                var realFileName = Path.GetFileName(strPathName);
                                var userfileid = 0;
                                if (extension != null)
                                {
                                    userfileid = InsertFileInDb(userID, realFileName, address, extension.ToUpper(), oHttpPostedFile.ContentLength / 1024, 0);
                                }
                                var writePathName = HttpContext.Current.Server.MapPath(string.Format("~/UserFiles/{0}/{1}", userID, userfileid + "-" + realFileName));
                                oHttpPostedFile.SaveAs(writePathName);

                                var backupDirectory = HttpContext.Current.Server.MapPath(string.Format("~/UserFiles/{0}/BackUp", userID));
                                if (Directory.Exists(backupDirectory) == false)
                                    Directory.CreateDirectory(backupDirectory);
                                oHttpPostedFile.SaveAs(backupDirectory + "/" + userfileid + "-" + realFileName);

                                return strFileName;

                            }

it's not related to path issues because i can upload small file but when i change my web config to upload large file, in large file i got this error.
what do you think? its not related to :
XML
<system.webServer>
   <security>
       <requestFiltering>
           <requestLimits maxAllowedContentLength="200000000"/>
        </requestFiltering>
   </security>
</system.webServer>


thank you so much.
 
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