How to apply watermark in file upload control [duplicate] - javascript

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Putting placeholder attribute on file type input field
i want to show something like this..
I have one file-upload control and need to show some value in default file-upload control text box. how it is possible.

Can you try using
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/TextBoxWatermark/TextBoxWatermark.aspx
because it works for sure with textbox but i have not tried with file upload control.

Related

automaticly insert text in input [duplicate]

This question already has answers here:
How to focus on a form input text field on page load using jQuery?
(12 answers)
Closed 2 years ago.
Is there a way that if someone enters a site, everything that he writes will be entered in an input automatically so he doesn't need to click on it?
If already searched in the Internet, but I found nothing.
Add focus to your input by below line.
document.getElementById('search').focus();
See Demo
document.getElementById('search').focus();
<input id="search">
Well, here's the way I think:
document.querySelector('#your-input-id').focus();

Changing the "<URL name> says:" header to confirm dialog box [duplicate]

This question already has answers here:
How to edit a JavaScript alert box title?
(10 answers)
Closed 6 years ago.
When using the confirm dialog box in Javascript, the first line is "<URL name> says:" then it is followed by the string specified in the js call.
Is there a way to change that first line?
The confirm box, just like the alert box, is a system object, and not subject to CSS. To do this style of thing you would need to create an HTML element and mimic the confirm() functionality.
What you want is not possible, the url in the confirm window is not customizable. As a solution you could create your own modal box and style it as desired.

Set input file value to second input file [duplicate]

This question already has answers here:
How to set file input value when dropping file on page? [duplicate]
(1 answer)
Dynamically set value of a file input [duplicate]
(4 answers)
How to set a value to a file input in HTML?
(10 answers)
Closed 9 years ago.
Note:
The answers & comments below reflect the state of legacy browsers in 2009. Now you can actually set the value of the file input element dynamically/programatically using JavaScript in 2017.
See the answer in this question for details as well as a demo:How to set file input value programatically (i.e.: when drag-dropping files)?
I have 2 input type="file"
<input type="file" id="attach_file_1" name="attach_file_1" />
<input type="file" id="attach_file_2" name="attach_file_2" />
after "choosing" file for attach_file_1, there is possible to set same value for attach_file_2 using javascript ?
I don't think you can. I believe it's a security issue. You can't set the value of a file input type. Otherwise you could hide the file input element and upload a file to your server without the user's knowledge.
One way of achieving the desired functionality is to add a flag in form and mark it true when you want to copy the file information to second input. Then, on the server, you can check for that flag and use the file from first input to do whatever you wish to do with the second input.
Given that you want another input with the same value, it does appear to be possible using .cloneNode(), at least in Firefox. So far, Chrome behaves differently.
http://jsbin.com/ohafom/2/
Also note that I haven't actually tested the upload. As far as I know, Firefox will only send one. Still interesting that the clone worked.
The only way I can figure out to achieve that (but works only to "pass" the file from one to another) is to dynamically switch the input field position and names so that the file looks like it have passed from one to another.
Otherwise, it's security issue, most browsers won't let you manipulate file inputs at all.

Set default value for a input file form [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Dynamically set value of a file input
I have an input file HTML form and I want to set the initial value for the file path in an HTML form . I try to change tag "value" but it doesn't work anyway.
<input type="file" name="testcase" value= "C:\test.txt">
Please give me some advice for this small problem. Thanks.
From HTMLHelp.com :
The file input type creates a field
through which users can upload files
from their local computer or network.
The VALUE attribute specifies the name
of the initial file, but it is
typically ignored by browsers as a
security precaution.
Therefore, setting an initial value is not supported.

Dynamically set value of a file input [duplicate]

This question already has answers here:
How to set file input value when dropping file on page? [duplicate]
(1 answer)
How to set File objects and length property at FileList object where the files are also reflected at FormData object?
(1 answer)
Closed 6 years ago.
Is there a way to set the value of a file input (<input type="file" />) or is that all blocked for security? I'm trying to use google gears' openFiles to make a simple multi-uploader.
Note:
The answer(s) below reflect the state of legacy browsers in 2009. Now you can actually set the value of the file input element dynamically/programatically using JavaScript in 2017.
See the answer in this question for details as well as a demo:How to set file input value programatically (i.e.: when drag-dropping files)?
It is not possible to dynamically change the value of a file field, otherwise you could set it to "c:\yourfile" and steal files very easily.
However there are many solutions to a multi-upload system. I'm guessing that you're wanting to have a multi-select open dialog.
Perhaps have a look at http://www.plupload.com/ - it's a very flexible solution to multiple file uploads, and supports drop zones e.t.c.
I am working on an angular js app, andhavecome across a similar issue. What i did was display the image from the db, then created a button to remove or keep the current image. If the user decided to keep the current image, i changed the ng-submit attribute to another function whihc doesnt require image validation, and updated the record in the db without touching the original image path name. The remove image function also changed the ng-submit attribute value back to a function that submits the form and includes image validation and upload. Also a bit of javascript to slide the into view to upload a new image.
I ended up doing something like this for AngularJS in case someone stumbles across this question:
const imageElem = angular.element('#awardImg');
if (imageElem[0].files[0])
vm.award.imageElem = imageElem;
vm.award.image = imageElem[0].files[0];
And then:
if (vm.award.imageElem)
$('#awardImg').replaceWith(vm.award.imageElem);
delete vm.award.imageElem;
I had similar problem, then I tried writing this from JavaScript and it works! : referenceToYourInputFile.value = "" ;

Categories