I'm using a rad window to upload some files to the server. When I upload the first time it works, how ever if I use the same form and upload a second time, it saves the file twice in the target folder. Once with the name I give in in the function below and the other file is without the appended documentid. So i get two files like this: 143test.txt and test.txt.
Here is my bindresults function that is called on the sumbit click. Any ideas? Its as if the inital save uses the default temp folder and then on subsequent saves it changes the temp folder to the targetphysical path.
private void BindResults()
{
thisUser = new User(SessionHandler.UserID);
string folderpath = ConfigurationManager.AppSettings["AttachmentsLocation"].ToString();
RadUpload1.TargetPhysicalFolder = folderpath;
string targetFileName = "";
foreach (UploadedFile f in RadUpload1.UploadedFiles)
{
string ext = f.GetExtension().Replace(".", "");
int size = f.ContentLength;
double fsize = Convert.ToDouble(size) / 1000;
Int32 docid = DataAccess.SaveDocument(thisUser.UserID, f.FileName, ext, "", fsize);
targetFileName = Path.Combine(folderpath, docid.ToString() + f.FileName);
f.SaveAs(targetFileName);
int attachmentid = DataAccess.DocumentAttach(docid, Convert.ToInt32(Request.QueryString["todoid"].ToString()), AllItemTypes.ToDo);
}
}
Here is my bindresults function that is called on the sumbit click. Any ideas? Its as if the inital save uses the default temp folder and then on subsequent saves it changes the temp folder to the targetphysical path.
private void BindResults()
{
thisUser = new User(SessionHandler.UserID);
string folderpath = ConfigurationManager.AppSettings["AttachmentsLocation"].ToString();
RadUpload1.TargetPhysicalFolder = folderpath;
string targetFileName = "";
foreach (UploadedFile f in RadUpload1.UploadedFiles)
{
string ext = f.GetExtension().Replace(".", "");
int size = f.ContentLength;
double fsize = Convert.ToDouble(size) / 1000;
Int32 docid = DataAccess.SaveDocument(thisUser.UserID, f.FileName, ext, "", fsize);
targetFileName = Path.Combine(folderpath, docid.ToString() + f.FileName);
f.SaveAs(targetFileName);
int attachmentid = DataAccess.DocumentAttach(docid, Convert.ToInt32(Request.QueryString["todoid"].ToString()), AllItemTypes.ToDo);
}
}