public ActionResult Index(PublishPost post, HttpPostedFileBase f)
string apiUrl = "http://myurl.com"
WebClient Client = new WebClient();
byte rb = Client.UploadFile(apiUrl, "POST", f.FullName);
string response = Encoding.UTF8.GetString(rb);
The path of
httppostefilebase is showing --
C:\Windows\SysWOW64\inetsrv\adminrights.JPG but it is giving error with webclient -
Path not found. Please help
Best How To :
To upload a file using
HttpPostedFileBase you can use following snippet:
public void UploadFile(HttpPostedFileBase file)
var folderName = "/Content/Upload/Images/";
var fileName = file.FileName;
using (var fileStream = File.Create(BasePath + folderName + fileName))
Folder where your files are uploaded is not a case as long as IIS has right to write to it.
To delete file just refer to https://msdn.microsoft.com/en-us/library/system.io.file.delete(v=vs.110).aspx
I don't know what you mean by asking whether to delete file after uploading - it depends on your intentions.