Click here to Skip to main content
15,918,808 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Good Afternoon Friends

Please suggest me to solve this problem :


when we upload image file (or any file) we are storing file name & file path in database...

and file was storing in one folder ...

When we are retrieving file name we are getting file name from database, based on file name respective file is displaying from folder...

This was executing in local machine fine...

but when we upload into server file was not storing into folder which is present in server.

But retrieving is good (working fine)

I tested with default file stores in folder in server.

That file is retrieving fine.

But the problem is When i browse any file that file should store in folder which is in server.

This is the problem we are facing...

To store that we taken handler.ashx file in c#.

C# Code in Handler1.ashx :

C#
string fileName = "";

               string SaveLocation = HttpContext.Current.Server.MapPath("flex-bin/assets/Uploads/");
               if (context.Request.Files.Count == 0)
               {

                   context.Response.Write("True");
               }
               else
               {
                   foreach (string filekey in context.Request.Files)
                   {
                       HttpPostedFile file = context.Request.Files[filekey];
                       file.SaveAs(SaveLocation + file.FileName);
                       fileName = file.FileName;
                   }
                   context.Response.Write("upload: " + SaveLocation + fileName);
               }

Flex Code for FileUpload :

C#
public var f1:FileReference=new FileReference();
public var imgName:String;

protected function btnAddBrochure_clickHandler(event:MouseEvent):void
			{
				f1.addEventListener(Event.SELECT, selectedManageBrochures);
				f1.browse();
				
				
			}

protected function selectedManageBrochures(event:Event):void
			{
				var request:URLRequest=new URLRequest("http://localhost:1149/Handler1.ashx");
				try
				{
					
					f1.upload(request);
					imgName=event.target.name;
					
				}
				catch(error:Error)
				{
					trace(error);
				}
				
			}
File should store in http://bria.indusrays.com/flex-bin/Uploads/

(Uploads is folder in flex-bin folder)

Please give suggesion to overcome this problem
Posted
Updated 21-May-13 22:34pm
v2
Comments
vijay__p 22-May-13 4:44am    
Have you given write permission on that folder on server ?
Member 9409254 22-May-13 6:13am    
i didn't verify that vijay
i will verify it now
Mahesh Bailwal 22-May-13 4:44am    
Are you getting any exception?
Member 9409254 22-May-13 6:12am    
No mahesh iam not getting any exception it was showing uploaded successfull. but file was not stored in folder in server.
tumbledDown2earth 23-May-13 0:26am    
Sounds like your app-pool user doesnt have write permission on 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