Modify Filename and Insert Into DB Issue

6 posts, 1 answers
  1. Matt
    Matt avatar
    13 posts
    Member since:
    Aug 2015

    Posted 22 Sep 2015 Link to this post

    I'm having  a hard time wrapping my brain around this one!  The AsyncUpload is going to be part of a form that captures other information about the document. The file will be uploaded to the server and a new record is inserted into the database. As part of this, I am also modifying the filename.

    My issue is that the file is moving out of the temporary location before any of the service side code is run. It IS uploaded OK and moving to the right folder. But it is doing it immediately at the form's submit button click so I am unable to change it's filename. This then causes my script to error out because it can't find the temporary file (it is already removed).

    I'm sure this is a rookie question! But please take a look at this code. Thanks!

     

        protected void btnDocUpload_Click(object sender, EventArgs e)
        {
            foreach (UploadedFile file in RadAsyncUpload1.UploadedFiles)
            {
                //we are going to rename the file with the Catnumber + the date
                string newDocName = txtCatNumber.Text + DateTime.Now.ToString("M-d-yyyy");

        docBL doc = new docBL();
                doc.DocumentUpload(txtCatNumber.Text, newDocName);

                file.SaveAs("_SDFiles_\\" + newDocName + file.GetExtension(), true);
            }
        }

  2. Ralf
    Ralf avatar
    3 posts
    Member since:
    Dec 2014

    Posted 23 Sep 2015 in reply to Matt Link to this post

    Hi Matt,

     just as a hint: You do know that you can control where the control saves the file temporary and where to move it to after a successful processing ?

    Check last 2 options in the markup:
    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" MultipleFileSelection="Disabled"  MaxFileInputsCount="1" Skin="Bootstrap"  TargetFolder="C:\temp\
    " TemporaryFolder="c:\mytemp\"></telerik:RadAsyncUpload>

    BR,

    Ralf

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 25 Sep 2015 Link to this post

    Hi Matt,

    Make sure that the TargetFolder property is NOT defined.

    Regards,
    Hristo Valyavicharski
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. Matt
    Matt avatar
    13 posts
    Member since:
    Aug 2015

    Posted 28 Sep 2015 Link to this post

    Thanks - I DID have the TargetFolder assigned in the properties. Removing that solved my issue. And thanks, Ralf - I will explore the post-processing move property as well.

    Can the target folder be relative? Or does it have to be an absolute path? My Production server's file paths would be a little different.

  6. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 29 Sep 2015 Link to this post

    The path can be relative, but Virtual Folders cannot be used.

    Regards,
    Hristo Valyavicharski
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. Matt
    Matt avatar
    13 posts
    Member since:
    Aug 2015

    Posted 29 Sep 2015 Link to this post

    This post helped me solve my problem with uploading to a relative path folder. Thanks.

    http://www.telerik.com/forums/a-simple-upload-and-save-file-in-a-folder#pKDBdy2azUelc2m6hfbi1Q

     ​

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017