File Upload to another server [modified]
-
Hi guys I got a bit of a problem that has taken me days to try and sort out and I'm getting nowhere. basically I have to servers that are setup in a DMZ, as a workgroup, one server is a Application Server and the other is a Database and File Server. I need to be able to be able to upload files from the application server the file server via a UNC path. but everything I have tried seems to fail. I recieve errors along the lines of "can't find part of path", "incorrect user/password", etc. I have tried a Myriad of approaches including creating a user account on both machines, and impersonating that account, to write, Created a Virtual Directory and used : string SaveLocation =System.Web.Hosting.HostingEnvironment.MapPath ("~/webmedia/article/" + fn ) To get the UNC path, Stored the UNC path in the Web.config file, but nothing seems to work. I haved scoured the net for any information, but seem to have got nowhere, I have found one or two articles but they basically tell me what I have tried. I was wondering if anybody knows of any other Tut's/atricles I could read. I have included some of my code in the help somebody could spot an error
HttpPostedFile selectedPDF = ImageUploadFile.PostedFile; if ((selectedPDF != null) && (selectedPDF.ContentLength > 0) && selectedPDF.ContentType == "application/pdf") { try { string fn = System.IO.Path.GetFileName(selectedPDF.FileName); string dir = ConfigurationManager.AppSettings["docpath"].ToString(); // string SaveLocation =System.Web.Hosting.HostingEnvironment.MapPath ("~/webmedia/article/" + fn ); string SaveLocation = ConfigurationManager.AppSettings["devdocpath"].ToString() + fn; selectedPDF.SaveAs(SaveLocation); .....
-- modified at 8:47 Wednesday 7th November, 2007 I have tried doing a simple app here locally on my own network and haven't even tried using impersonation, but it just works here is the sample code. I am completely baffledtry { HttpPostedFile theFile = FileUpload1.PostedFile; //System.IO.Path.GetFileName(selectedPDF.FileName) FileUpload1.SaveAs(@"\\Cyko\d\" + System.IO.Path.GetFileName(theFile.FileName).ToString()); }
Kind Regards, Gary
My Website ||