5

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 ?

Er.Er
  • 135
  • 2
  • 14

1 Answers1

4

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)

Matt Ellen
  • 11,268
  • 4
  • 68
  • 90
  • 1
    I can still add txt or something if I change custom files to all files when open file select window – Er.Er Oct 20 '17 at 07:27