Как загрузить файл с клиентского компьютера на сервер с помощью webservice
How to upload a file from client machin to server by using webservice I have created webservice using C#.That take filepath/url(object from client pc ,not hosted anywhere),convert to byte array.And using that create a file on server location.Below code working fine on local machine.I uploaded file from C drive to D drive.But when I hosted service on server not localhost and trying to access,file not get uploaded and getting msg like this : Could not find file 'C:\Fileupload\test.txt'..Client can send only url of file that from local machine not hosted anywhere can not send byte array.Is there any option apart from creating new file in server.Can I directly upload like fileuploadcontrol.Client can either use web app or windows app or windows service for uploading
Что я уже пробовал:
Here is my code : string uploadFolder = = @"D:\UploadFiles\"; [WebMethod] public string UploadFile(string filePath) { try { byte[] f = System.IO.File.ReadAllBytes(filePath); MemoryStream ms = new MemoryStream(f); uploadFolder = uploadFolder + StrFilename; // StrFilename extracted from filepath FileStream fs = new FileStream(uploadFolder, FileMode.Create); ms.WriteTo(fs); ms.Close(); fs.Close(); fs.Dispose(); return "OK"; } } catch (Exception ex) { // return the error message if the operation fails return ex.Message.ToString(); } }