Copied to clipboard

Flag this post as spam?

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


  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    May 09, 2011 @ 17:37
    Jeroen Breuer
    0

    Check if new file is uploaded

    Hello,

    I've got a media before save event and in that event I would like to check if a new file has been uploaded with the upload datatype. Some parts of the event only need to be triggerd (like resizing) if a new file is uploaded. Any idea how I can check this?

    Jeroen

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    May 10, 2011 @ 13:51
    Jeroen Breuer
    0

    Anyone know how I can do this?

    Jeroen

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    May 18, 2011 @ 21:38
    Jeroen Breuer
    0

    I fixed it by using File.GetLastWriteTime

    Property pathProp = new Media(mediaId).getProperty("umbracoFile");
    if (pathProp != null && pathProp.Value != null && !string.IsNullOrEmpty(pathProp.Value.ToString()))
    {
        //Get the date when the file was last modified.
        DateTime modification = File.GetLastWriteTime(HttpContext.Current.Server.MapPath(pathProp.Value.ToString()));

        //Check if the file is updated less than a minute ago.
        isUpdated = modification > DateTime.Now.AddMinutes(-1);
    }

    Jeroen

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies