Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i was save the file into server folder. but it not working .
but in locally working
Posted
Comments
Gihan Liyanage 17-Sep-14 6:36am    
Need more information or code sample..
Member 10229796 17-Sep-14 6:59am    
string str;
string strFilePath;
string strFileName;
strFilePath = FileUpload1.FileName;
if (!System.IO.Directory.Exists(Server.MapPath("~/PublicRelations/UploadFiles/")))
{
System.IO.Directory.CreateDirectory(Server.MapPath("~/PublicRelations/UploadFiles/"));
}

string[] strFileSplit = strFilePath.Split('\\');
strFileName = strFileSplit[strFileSplit.Length - 1];
str = strFileName.Substring(0, strFileName.IndexOf("."));

str += "_" + System.DateTime.Now.Day + "_" + System.DateTime.Now.Month + "_" + System.DateTime.Now.Year;
str += "_" + System.DateTime.Now.Hour + "_" + System.DateTime.Now.Minute + "_" + System.DateTime.Now.Second;
str += strFileName.Substring(strFileName.IndexOf("."));
string strImagePath = HttpContext.Current.Server.MapPath("~/PublicRelations/UploadFiles\\" + str);

ViewState["FileName"] = str;
FileUpload1.SaveAs(strImagePath);
Kornfeld Eliyahu Peter 17-Sep-14 8:08am    
It may be connected to the size of the file you are saving...Try firs with a very small one...

Hi there,

I think to check and create the directory you are using "System.IO" namespace which is used to perform the IO operations on your local system.Thats why your code is running properly on local machine.

Hope it will help you out.
 
Share this answer
 
You need to make sure that the server doesn't have anything set relative to the time out thing.

I believe the sockets are closed for that connection disabling the transfer. As already suggested, you can chop down the data size. Since on the local server, you don't have to worry about the size of the files, you get a lot of bandwidth (well you don't even have to worry about bandwidth on localhost) but on the remote servers like hosting server you have to worry about it. More file size and less network bandwidth can cause these troubles.

You can chop the files into packets like if there are 10 files, send 5 in one time and 5 in next time.
 
Share this answer
 
Comments
Member 10229796 22-Sep-14 8:53am    
thanks for your valuable answers.i was rectified the error.
the error was I am not give the folder permissions in the server

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