Support » Plugin: Frontend Uploader » How to Set Maximum MP3 File Size

  • Hi, is there a shortcode for setting the maximum file size for a file type?

    Having set mp3 as the default file type I’d like to restrict uploads to mp3 only and limit the size to 6 mb. I don’t want the limit the size across the entire site, just in the plugin uploader.

    I’m thinking some javascript could be enqueued via some filter:

    var uploadField = document.getElementById("file");
    
    uploadField.onchange = function() {
        if(this.files[0].size > 1307200){
           alert("File is too big!");
           this.value = "";
        };
    };

    Thanks for any guidance.

Viewing 1 replies (of 1 total)
  • It seems it might be simpler to use
    apply_filters( 'upload_size_limit', int $size, int $u_bytes, int $p_bytes )
    with a hook.

    What might that be?

Viewing 1 replies (of 1 total)
  • The topic ‘How to Set Maximum MP3 File Size’ is closed to new replies.