RadUpload In Window Saving Twice

Thread is closed for posting
3 posts, 0 answers
  1. John
    John avatar
    88 posts
    Member since:
    Nov 2007

    Posted 18 Feb 2008 Link to this post

    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);
                int attachmentid = DataAccess.DocumentAttach(docid, Convert.ToInt32(Request.QueryString["todoid"].ToString()), AllItemTypes.ToDo);
  2. Petya
    Petya avatar
    869 posts

    Posted 19 Feb 2008 Link to this post

    Hi John,

    The reason you experience this problem is that on first submit you set RadUpload1.TargetPhysicalFolder = folderpath. So, on next submit the selected file is first automatically saved because you have specified a TargetPhysicalFolder and then it gets saved by your code f.SaveAs(targetFileName). Why do you set RadUpload1.TargetPhysicalFolder? Specifying TargetPhysicalFolder/TargetFolder property activates the process of automatically saving the uploaded file to the specified folder.

    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. John
    John avatar
    88 posts
    Member since:
    Nov 2007

    Posted 19 Feb 2008 Link to this post

    Thanks, I wasn't sure what I was doing, but this now makes sense to me.  Thanks.
Back to Top