input-type-file

IE doesn't allow to upload the file, if it is not keybord click for input type=file

十年热恋 提交于 2020-01-05 05:46:05
问题 I have a requirement where i need to trigger the input[type=file] from another button and upload the files. This input[type=file] is a popup window for browsing the file which the user wants to upload. This window opens successfully but when uploading the file, it gives me SCRIPT5: Access is Denied error . I cannot replace the fake button with input[type=file], is there a way i can trigger click on input[type=file] even it is not from keyboard click and still upload the file. As per my

jQuery input file click method and access denied on IE

血红的双手。 提交于 2019-12-22 12:28:30
问题 I'm trying to use only a button as input file, it works fine in Firefox, Chrome, Safari but not in IE... I always get 'access denied' when submitting the form. The code: $('#input_file').click(); Is there a real fix for it? I wasted about 2 hours on google but I can't find it. 回答1: I found a way around it. Wrap the button in label tags like this: <label for="fileinput"><div class="button">Upload file</div></label> <form> <input id="fileinput" name="file" type="file"> </form> Clicking the

How to display a image selected from input type = file in reactJS

社会主义新天地 提交于 2019-12-09 06:03:03
问题 I'm trying to display a image selected from my computer in my web app. I referred the following question which addresses the question i'm trying to fix. How to display selected image without sending data to server? I have my html part like this <div className="add_grp_image_div margin_bottom"> <img src={img_upload} className="add_grp_image"/> <input type="file" className="filetype" id="group_image"/> <span className="small_font to_middle">Add group image</span> <img id="target"/> </div> I

How to set an image as a background image in html using input type=“file”?

谁说胖子不能爱 提交于 2019-12-08 15:33:55
问题 I am creating a web page that can receive an image and set it as a background image. My work till now: function a(a) { document.body.style.backgroundImage = "url(a.value)"; } <input type="file" onchange="a(this);"> Since the value comes as C:\fakepath\Image.extension , the background doesn't changes. So, can you please help me to do this using javascript only. I know this is a very strange question. But it will help me to learn something new and can help others too. 回答1: You need to read the

how to force input type file to accept only .html or .htm files

送分小仙女□ 提交于 2019-12-07 07:51:17
问题 here i am trying to upload html/htm files on the click of a button. For that i am using 'input type=file' I have set the 'accept' attribute of it to accept only html/htm extensions like this: <input type="file" name="htmla" id="htmla" accept="text/html" /> But it is showing different behaviour in different browsers In firefox, it is accepting all files In chrome, it is accepting html as well as images In IE, the same as firefox Is there a way to make it accept only html/htm files by any

jQuery input file click method and access denied on IE

牧云@^-^@ 提交于 2019-12-06 06:19:38
I'm trying to use only a button as input file, it works fine in Firefox, Chrome, Safari but not in IE... I always get 'access denied' when submitting the form. The code: $('#input_file').click(); Is there a real fix for it? I wasted about 2 hours on google but I can't find it. I found a way around it. Wrap the button in label tags like this: <label for="fileinput"><div class="button">Upload file</div></label> <form> <input id="fileinput" name="file" type="file"> </form> Clicking the label will trigger the file input without invalidating the form in internet explorer (tested in IE9 & IE10) EDIT

How to check an input type=“file” has a file or not using jquery?

女生的网名这么多〃 提交于 2019-12-06 02:23:59
问题 I have a file upload control <input id="File1" type="file" /> in my page... How to check an input type="file" has a file or not using jquery on click of a button upload ? 回答1: if (jQuery('#File1').val()) { /* There are files */ } 回答2: You should use "required" instead of JQuery. By just one attribute it'll check input=file has file or not. Example: <input type="file" required/> 回答3: $('#upload').bind('click', function(e){ if( $('#File1').val() != ""){ // file selected } else{ // no file

how to force input type file to accept only .html or .htm files

旧街凉风 提交于 2019-12-05 17:12:40
here i am trying to upload html/htm files on the click of a button. For that i am using 'input type=file' I have set the 'accept' attribute of it to accept only html/htm extensions like this: <input type="file" name="htmla" id="htmla" accept="text/html" /> But it is showing different behaviour in different browsers In firefox, it is accepting all files In chrome, it is accepting html as well as images In IE, the same as firefox Is there a way to make it accept only html/htm files by any method like javascript or jquery? Note: I am using this control in MVC 4 There is nothing in standard input

How to check an input type=“file” has a file or not using jquery?

一曲冷凌霜 提交于 2019-12-04 07:31:49
I have a file upload control <input id="File1" type="file" /> in my page... How to check an input type="file" has a file or not using jquery on click of a button upload ? Quentin if (jQuery('#File1').val()) { /* There are files */ } Hardik Sondagar You should use "required" instead of JQuery. By just one attribute it'll check input=file has file or not. Example: <input type="file" required/> jAndy $('#upload').bind('click', function(e){ if( $('#File1').val() != ""){ // file selected } else{ // no file selected } }); 来源: https://stackoverflow.com/questions/2642970/how-to-check-an-input-type

Validate input type=file with onBlur

帅比萌擦擦* 提交于 2019-12-02 17:54:35
问题 I'm able to use onBlur to validate type=text or textarea inputs, however I haven't been able to get the same to work for type=file. This works: <input type='text' name='sometextfield' size=30 class='input' onBlur="alert('Frell me dead, it works!');" This does not (no error): <input type='file' name='file_upload' size=30 class='input' onBlur="alert('Frell me dead, it works!');"> What is the trick to validating type=file input boxes, on the fly? I'd like to do this in vanilla Javascript. I'm