Document upload without going into the back end? - General Discussions - General Discussions - Progress Community
 General Discussions

Document upload without going into the back end?

  • Document upload without going into the back end?
  • 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? 

  • Hi John,

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

    - 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.
            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.
            //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.

    Svetoslav Manchev
    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
  • 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.
  • @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

    ...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...
  • @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?




  • 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 widget created...available to add to your toolbox and use right away!