+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Document upload without going into the back end?

Document upload without going into the back end?

6 posts, 0 answered
  1. John
    John avatar
    51 posts
    Registered:
    11 Apr 2013
    10 Jun 2015
    Link to this post

    Does anyone know of method or module that will allow document upload and/or content editing in place without the user having to go into the backend?

    i.e. I have an intranet and would like to allow pages in the HR section to be edited and maintained by HR personnel without having to let them into the back end. Does anyone know of a method or module that will allow this? 

  2. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    07 Dec 2016
    12 Jun 2015
    Link to this post
    Hi John,

    You can create custom widget where to use <asp:FileUpload> control. For example:
    - Markup:
    <asp:FileUpload
        id="FileUpload1"
        runat="server" >
    </asp:FileUpload>
       
     <asp:Button id="UploadButton"
        Text="Upload file"
        OnClick="UploadButton_Click"
        runat="server">
    </asp:Button>

    - Code behind:
    protected void UploadButton_Click(object sender, EventArgs e)
    {             
        if (this.FileUpload1.HasFile)
        {
            LibrariesManager librariesManager = LibrariesManager.GetManager();
            Document document = librariesManager.CreateDocument(Guid.NewGuid());
     
            DocumentLibrary documentLibrary = librariesManager.GetDocumentLibraries().Where(d => d.Title == "Default Library").SingleOrDefault();
            document.Parent = documentLibrary;
            document.Title = this.FileUpload1.FileName;
            document.DateCreated = DateTime.UtcNow;
            document.PublicationDate = DateTime.UtcNow;
            document.LastModified = DateTime.UtcNow;
            document.UrlName = Regex.Replace(document.Title.ToLower(), @"[^\w\-\!\$\'\(\)\=\@\d_]+", "-");
     
            //Recompiles and validates the url of the document.
            librariesManager.RecompileAndValidateUrls(document);
     
            string path = Server.MapPath("~/");
           //saves the file in your project folder
            this.FileUpload1.SaveAs(path + FileUpload1.FileName);
            string documentPath = Server.MapPath(this.FileUpload1.FileName);
     
            FileStream fileStream = new FileStream(documentPath, FileMode.Open);
     
            string extension = Path.GetExtension(documentPath);
            //Upload the document file.
            librariesManager.Upload(document, fileStream, extension);
     
            //Save the changes.
            librariesManager.SaveChanges();
     
            //Publish the DocumentLibraries item. The live version acquires new ID.
            var bag = new Dictionary<string, string>();
            bag.Add("ContentType", typeof(Document).FullName);
            WorkflowManager.MessageWorkflow(document.Id, typeof(Document), null, "Publish", false, bag);
        }
    }

    I hope this helps.

    Regards,
    Svetoslav Manchev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. John
    John avatar
    51 posts
    Registered:
    11 Apr 2013
    06 Aug 2015 in reply to Svetoslav Manchev
    Link to this post
    How do I create that widget so that I can hand it off to my system admins to deploy to a production environment? is it built as a dll? or is there a way to package it for deployment?  All of the videos and documentation shows that I deploy it thru visual studio but my VS does not have access to the production environment.
  4. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    06 Aug 2015 in reply to John
    Link to this post

    @John

    You should create a new assembly project, add your widget(s) into that.  Then you can just hand it off to your admins to plop in the "bin" folder, which will recycle the site. 

     You can follow this code sample to auto-add the widget(s) to your toolbox

    http://www.sitefinity.com/blogs/peter-marinovs-blog/2013/03/20/creating-self-installing-widgets-and-modules-in-sitefinity

    ...or just do it manually when they tell you it's been added.


    If you create your widgets in your SF project then you'll need to provide them the actual SitefinityWebApp.dll, I prefer the separation of concerns...
  5. John
    John avatar
    51 posts
    Registered:
    11 Apr 2013
    06 Aug 2015 in reply to Steve
    Link to this post

    @Steve,

    When you say a new assembly project are you talking just a plain old VS assembly project or some sort of special assembly project thru thunder or with Sitefinity templates?

     

    TIA

     

  6. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    06 Aug 2015 in reply to John
    Link to this post

    Plain, Add->New Project->Class Library

    Then in your SF project, reference that project, and in that project add references back to like Telerik.Sitefinity, Telerik.Sitefinity.Model, Telerik.Sitefinity.Utilities or whatever you might need.

    If you have Sitefinity Thunder installed you can jsut right-click the Class Library (or a folder in it) and 

    Add->New Item->Sitefinity->Sitefinity Widget with Designer

    build...new widget created...available to add to your toolbox and use right away!

6 posts, 0 answered