I know this is a common problem facing, but I get this problem with a different scenario. i'm going to explain the script here
I created two different projects in the solution. The image containing the folder that I want to use for saving, ie loading is outside of these above projects, but under the same solution. Actually I created virtual directly (My File Server) on the IIS server of this folder
here is my code.
private void SaveData() { string filename = Path.GetFileName(ImageUpload.PostedFile.FileName); string servpath = Server.MapPath(ConfigurationManager.AppSettings["TempFolder"]); ImageUpload.SaveAs(servpath + filename); string remoteServerPath = ConfigurationManager.AppSettings["ProductImagesPath"] + filename; try { WebClient client = new WebClient(); client.UploadFile(remoteServerPath, servpath + filename); } catch (Exception ex) { throw ex; } objProductsCustom.ProductName = txtProductName.Text; objProductsCustom.ProductDiscription = txtAddDiscription.Text; objProductsCustom.ProductPrice = txtPrice.Text; objProductsCustom.Quantity = txtQuantity.Text; objProductsCustom.ImagePath = "servpath" + filename; int productID = objProductsManager.CreatProduct(objProductsCustom); }
Where in try-catch I found that βThe remote server responded with an error: (405)β Valid method. βError. I'm stuck.
EDIT This is the remoteserverpath path:
http:
And this is the file that I upload to remoteserverpath:
C:\Documents and Settings\saltaf\My Documents\Visual Studio 2010\Projects \OnlineShoppingSystem\OnlineShoppingSiteAdminPanel\Temp\Images\untitled.bmp
And this is my call:
webclient.UploadFile(http://localhost/ProductImages/untitled.bmp,C:\Documents and Settings\saltaf\My Documents\Visual Studio 2010\Projects\OnlineShoppingSystem\OnlineShoppingSiteAdminPanel\Temp\Images\untitled.bmp)
source share