Hi everyone
I have multiple RadUpload controls, the problem is that a client may upload two files, with the same filename, so what I have done is create a simple File.Exists check and then saving the file, but it seems its saving each file before it even gets to my code. So its always creating a duplicate file.
I understand that this is happening because the RadUpload sends the file to the server automatically on postback, is there a way to "manually" upload each file?
Here is a sample of my code. I have many uploads, so I created an Array
Any ideas?
Thank you.
I have multiple RadUpload controls, the problem is that a client may upload two files, with the same filename, so what I have done is create a simple File.Exists check and then saving the file, but it seems its saving each file before it even gets to my code. So its always creating a duplicate file.
I understand that this is happening because the RadUpload sends the file to the server automatically on postback, is there a way to "manually" upload each file?
Here is a sample of my code. I have many uploads, so I created an Array
//LOG DOCUMENT ENTRIES RadUpload[] allUploads = new RadUpload[25] { uxUpload1, uxUpload2,..... };string fileToWritePath = "";string fileNameToSave = "";foreach (RadUpload uploadControl in allUploads){ foreach (UploadedFile f in uploadControl.UploadedFiles) { fileToWritePath = uploadControl.TargetPhysicalFolder + @"\" + f.FileName; if (File.Exists(fileToWritePath)) { fileNameToSave = f.GetNameWithoutExtension().ToString() + "_" + DateTime.Now.ToString().Replace(":", "").Replace("/", "") + f.GetExtension().ToString(); f.SaveAs(uploadControl.TargetPhysicalFolder + @"\" + fileNameToSave); } else { fileNameToSave = f.GetName(); f.SaveAs(uploadControl.TargetPhysicalFolder + @"\" + fileNameToSave); } Document document = new Document(fileNameToSave, documenPath, 0, user.UserID); }}Any ideas?
Thank you.