Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Stephen Davidson 216 posts 392 karma points
    Apr 29, 2013 @ 12:59
    Stephen Davidson
    0

    Trigger email when content is uploaded

    Great package and very easy to implement. I'm using this to allow website users to upload their CV...ideally i would like an email to be triggered to let me know new content has been uploaded to the media folder...would this need to be done via additional JS?

     

  • Emanuel 63 posts 283 karma points
    Apr 29, 2013 @ 13:19
    Emanuel
    1

    Hi Stephen,

    Triggering events is possible if you explore the (basic) API provided in the DLL. If you are comfortable with dealing with Umbraco projects in Visual Studio, all you need is to add a Global.asax to the project with the code below:


    using ...
    using Gecko.Uploadify;

    namespace Your.Namespace
    {
        public class Global : umbraco.Global
        {
            protected override void Application_Start(object sender, EventArgs e)
            {
                base.Application_Start(sender, e);
                UploadifyHandler.FileUploaded += new FileUploadedEventHandler(UploadifyHandler_FileUploaded);
                UploadifyHandler.FileSaved += new FileSavedEventHandler(UploadifyHandler_FileSaved);
            }

            void UploadifyHandler_FileUploaded(object sender, FileUploadedEventArgs e)
            {
                // use this event to check the uploaded file and maybe cancel the upload
                // e.Settings.Cancelled = true;
            }

            void UploadifyHandler_FileSaved(object sender, FileSavedEventArgs e)
            {
                // use this event to run any custom code AFTER the file is saved in Umbraco, like sending an email
                // e.Media will contain the umbraco.cms.businesslogic.media.Media object with the uploaded file
            }
        }
    }

     

    The two elements in bold represent two events you can hook up to: just after the file is uploaded and just after the file is saved/added to Umbraco. In your particular case, you would hook up to the FileSaved event and then trigger an email notification. You can even get the actual file from the Media object and add it as an attachment to your email.

    Emanuel

Please Sign in or register to post replies

Write your reply to:

Draft