最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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 ?

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 ?

Share Improve this question edited Nov 22, 2017 at 7:39 Er.Er asked Oct 19, 2017 at 12:02 Er.ErEr.Er 1452 silver badges14 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 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./docs/jquery-upload-file.php

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

发布评论

评论列表(0)

  1. 暂无评论