This question is locked. New answers and comments are not allowed.
Hi All
I amusing the RadUploadHandler and overriding certain methods in my .ahsx file but these methods never seem to be hit.
In the below code no file names are changed, no new directories are created. The file is still uploaded to the root of the target directory fine, but same filename as source.
public class DocumentRequiredUploadHandle : RadUploadHandler { private string newFileName = string.Empty; //Upload Parameters private string OppId = string.Empty; private string ClientName = string.Empty; private string FileNamePrefix = string.Empty; private string DirLoc = string.Empty; public override Dictionary<string, object> GetAssociatedData() { Dictionary<string, object> dict = base.GetAssociatedData(); if (!string.IsNullOrEmpty(newFileName)) { dict.Add("NewFileLocation", this.newFileName); } return dict; } public override bool SaveChunkData(string filePath, long position, byte[] buffer, int contentLength, out int savedBytes) { return base.SaveChunkData(filePath, position, buffer, contentLength, out savedBytes); } public override string GetFilePath(string fileName) { OppId = this.GetQueryParameter("OppId"); ClientName = this.GetQueryParameter("ClientName"); FileNamePrefix = this.GetQueryParameter("FileNamePrefix"); DirLoc = this.TargetPhysicalFolder + @"\" + OppId; if (!Directory.Exists(DirLoc)) { Directory.CreateDirectory(DirLoc); } string FilePath = string.Format(@"{0}\{1}", DirLoc, this.GetFileName(fileName)); return FilePath; } private string GetFileName(string fileName) { if (this.IsNewFileRequest()) { this.ResultChunkTag = string.Format("{0} {1} {2}", FileNamePrefix, ClientName, DateTime.Now.ToString("yyyyMMdd_hhmmss")); } else if (this.FormChunkTag != null) { this.ResultChunkTag = this.FormChunkTag; } if (this.ResultChunkTag != null) { int i = fileName.LastIndexOf('.'); if (i >= 0) { fileName = string.Format("{0}.{1}", this.ResultChunkTag, fileName.Substring(i + 1)); } } return this.newFileName = fileName; } }Regards
Nick wood
