I am working on Client side application.. need to upload a file.How could i save file on server using jquery as i am only sending the path of file through ajax and need to copy same file on server as on folder....Below is my code ..How do i copy that file to server??? Having Error on this. /// UploadFile is a Folder Name on which i have to save/copy the file. /// file is a string variable which stores only path of uploaded file.
string FileName = System.IO.Path.GetFileName(file);
string Extension = System.IO.Path.GetExtension(file);
string SaveLocation = HttpContext.Current.Server.MapPath("UploadFile") + "\\";
System.IO.File.Copy(file,SaveLocation,true);
if (System.IO.File.Exists(SaveLocation))
{
System.IO.File.Delete(SaveLocation);
}
//fileupload.SaveAs(FilePath);
System.IO.FileInfo fi = new System.IO.FileInfo(SaveLocation);
if (!fi.Exists)
{
msg = "File " + SaveLocation + " Does Not Exists";
}