Document upload without going into the back end?

Posted by Community Admin on 03-Aug-2018 01:37

Document upload without going into the back end?

All Replies

Posted by Community Admin on 10-Jun-2015 00:00

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? 

Posted by Community Admin on 12-Jun-2015 00:00

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
 

Posted by Community Admin on 06-Aug-2015 00:00

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.

Posted by Community Admin on 06-Aug-2015 00:00

@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

www.sitefinity.com/.../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...

Posted by Community Admin on 06-Aug-2015 00:00

@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

 

Posted by Community Admin on 06-Aug-2015 00:00

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!

This thread is closed