javascripthtmluploadjquery-file-upload

How to accept add just media files (video and photo) and No All Files section


I have this at html page

<input type="file" id="ajax-upload-id-1508413400253" name="Media" accept="video/*,image/*" 
style="position: absolute; cursor: pointer; top: 0px; width: 100%; height: 
100%; left: 0px; z-index: 100; opacity: 0;">

And at .js

 manageMedia_Uploader = $("#fileuploader").uploadFile({
            url: "/Ajax/JsonProvider?Method=SaveMedia",
            fileName: "Media",
            autoSubmit: false,
            multiple: false,
            acceptFiles: "video/*,image/*",
            dynamicFormData: function () {
                return { MediaFriendlyName: $("#ManageMedia-MediaFriendlyName").val(), MediaID: mediaID }
            },


SaveMedia: function (mediaID) {

        if (mediaID == 0) {
            manageMedia_Uploader.startUpload();
        } else {
             //util
        }
    },

My problem is I want to just add picture and video nothing else. Thanks for this code give me 2 option while selecting files. Custom files and All files.

acceptFiles: "video/*,image/*",

How can i prevent All Files section ? Just Custom Files will appear ?


Solution

  • First you need to add input type="file" attribute, to accept media files, you can do it like this : HTML

    <input type="file" id="ajax-upload-id-1508413400253" name="Media" accept="audio/*,video/*,image/*" 
    style="position: absolute; cursor: pointer; top: 0px; width: 100%; height: 
    100%; left: 0px; z-index: 100; opacity: 0;">
    

    JS

    manageMedia_Uploader = $("#fileuploader").uploadFile({
                url: "/Ajax/JsonProvider?Method=SaveMedia",
                fileName: "Media",
                autoSubmit: false,
                multiple: false,
                acceptFiles: "image/*, video/*",
                dynamicFormData: function () {
                    return { MediaFriendlyName: $("#ManageMedia-MediaFriendlyName").val(), MediaID: mediaID }
                },
    
    
    SaveMedia: function (mediaID) {
    
            if (mediaID == 0) {
                manageMedia_Uploader.startUpload();
            } else {
                 //util
            }
        },
    

    More :

    http://hayageek.com/docs/jquery-upload-file.php

    HTML Input="file" Accept Attribute File Type (CSV)