Copied to clipboard

Flag this post as spam?

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


  • Daniela 1 post 21 karma points
    Feb 24, 2011 @ 11:02
    Daniela
    0

    Upload file - how I avoid save

    Hi.

    I’m using Umbraco 4.5.2 and I have a document with an Upload property.

    I would restrict the upload only to pdf files with a size not too large.

    I created a class that captures the event Document_BeforeSave and I test sender.getProperty("umbracoFile").Value.ToString().Length > 0

    With debug, I note that, when I click on Save icon, the function is executed twice.

    Beginning of the first round, the folder under the Media with the id assigned to the property has not yet created. After the first round, the folder has been created and contains the uploaded file.

    In both function calls sender.getProperty("umbracoFile").Value.ToString() is equal to 0.

     

    I wanted to cancel the save (and avoid saving the file to the folder) if the file extension is different from the pdf but this is not possible because the value sender.getProperty("umbracoFile").Value.ToString() is always 0.

     

    How can I proceed?

     

    Another question: how I can display a red message on interface to alert the user that the file type is incorrect?

     

    Thanks.

     

    Daniela

Please Sign in or register to post replies

Write your reply to:

Draft