最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin8PV0评论

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)

Post a comment

comment list (0)

  1. No comments so far