Pre-Populate HTML form file input - html

I have a VBScript that goes over an HTML form, fills it with fixed values and then submit it. It works fine so far, but now i need to set the location of a file that is going to be uploaded within the form data.
I believed if I set the location on the value it was going to work, but it doesn't.
<input type='file' name="file_field" value='file_location'/>
Also, I found this while researching. It says...
input type=file
Value: Sets or retrieves the displayed value for the control object. This value is returned to the server when the control object is submitted.
Is there a way (by code) to fill that input, even with jQuery?

No. This is not possible.
Browsers block against setting the value attribute on input of file type for security reasons so that you can't upload a file without the user's selected any file himself.

Related

Is there a way to change an HTML image url to text entered in an input field WITHOUT using Javascript?

I am currently developing an online tabletop RPG character sheet (to be integrated with the Roll20 virtual tabletop), and would like to add support for the user to display a custom portrait of their character using a URL. Ideally, this would be via an input field on the sheet itself that would feed into the src attribute of an image, also on the sheet, which would then update with the given URL.
Unfortunately, Roll20's framework is heavily sandboxed and doesn't allow javascript at all, so I'm stuck with HTML and CSS only. With this limitation in mind, is there any way to achieve the user experience I'm looking for? (That experience being, the user sees an empty form input field and a blank image frame. The user pastes a URL into a form input field, and the image's src is then set to the URL given in the input, displaying the image.)
Add some inline js to the onchange event of the for input, eg
<input type='text' onchange="document.getElmentById(myImageId).src=this.value;" />
Yes, this is javascript, however unless your framework is clever enough to strip it out it should run.

URL to fill input fields

There is a website that I use regularly that has quite a few log in fields. I'm trying to formulate a link to pre-populate most of them.
The fields in question are formatted like this:
<input id="frm:User" type="text" name="frm:User" autocomplete="off" style="width:80%" />
I've tried using "http://website?frm:User=User&frmGroup=Group" to no avail. Any suggestions?
Thanks!
There exists no standard way to fill in HTML inputs by passing values into the URL's query string. The URL including the query string parameters is sent to the server as a request, and the server generates the HTML as a response. It's completely up to the remote server how to interpret the incoming query parameters and how to generate the HTML.
What is the reason exactly you want the fields for this particular site to be auto filled? Maybe a password manager like lastpass could do the trick for you?
If you are using Google Chrome, this can be done pretty easily with Autofill extension. All you need to do is:
Install Autofill extension.
Open the website page that you want to auto fill input fields. Activate the Autofill extension.
Fill the input fields manually and then save it to a profile.
Click "Generate Autofill Rules". Next time, when you visit this page, the input fields will be filled automatically.

How to write value to an input type = file of an form using php

I am able to write value to an input t form type= text
for ex
<input type="text" value="xyz">
But what i want is, to write a value to input type="file" . I have tried the code below but it's not working.
<input type="file" value="something">
You cannot, for fairly obvious security reasons.
If a webpage could specify a default value for a file input, then it could (for example) specify c:\place\where\finance\software\stores\accounts\by\default (and then use JavaScript to submit the form without the user having to do anything).
PHP aside, HTML doesn't let you assign values to input type="file" elements as a security measure. If HTML had this power, you could setup several of these fields and point each one to a windows file on the user's computer. The result would be a victim submitting a form with no idea they were also submitting sensitive information. No JavaScript is required. The victim might submit such a form to log in or post a comment on a blog somewhere. Why wouldn't the victim notice they are also submitting a file? CSS can style such elements offscreen using negative coordinates so its a lot like an input type="hidden", just in this case it would submitting a file instead.

How does the vcard_name attribute work re: input fields?

Can anyone explain how the (IE) vcard_name attribute works as applied to HTML input fields (see below)?
<input name="foo" vcard_name="bar">
I've read Microsoft's documentation but am still unclear. In the example above, does the inclusion of the vcard_name attribute mean that AutoComplete suggestions will be drawn exclusively from the Profile Assistant? Or will suggestions be drawn from both the Profile Assistant and the standard autocompletion store?
Also, does the inclusion of the vcard_name attribute mean that the user's input will be saved in the Profile Assistant when the form is submitted?
Hope this will help you.
Thanks
How It Works (Basically)
When you enter information into a form and submit it, Internet Explorer sets up what's known as a vCard. The reason the function is so successful is that Web authors tend to use the same NAME attributes for many form elements across pages.
For instance, I'll bet you've filled out a ton of forms that ask for your name. Allow me to demonstrate. Type the first few letters of your name in the text box just below. If you're using IE 5.0 or above, I'll bet your name appears as a choice you can make. Try it in the e-mail box, too. I'll bet you get your e-mail as a choice. It won't work for everyone, but I'll bet I get the majority of you:
If it worked for you, and I'll bet it did, you're probably wondering how I knew each item would come up. Well, first off, here's the code from the form above:
<FORM>
Name: <INPUT TYPE="text" NAME="name">
E-mail: <INPUT TYPE="text" NAME="email">
</FORM>
It's the NAME attribute that does the trick. I'm basically making a guess that sometime, somewhere, you filled out a form that asked for your name and e-mail address. In addition, I am guessing that the form used the NAME attributes "name" and "email". They are very common.
If it worked, then you have a couple of vCards on your system named "VCARD_NAME" and "VCARD_EMAIL". When you filled out the other form and submitted it, the card was created. Now, from that point on, whenever you run into a form that has an element with a NAME attribute set to "name" or "email," the text from that vCard will be suggested to you.
Let me attempt to prove that point again. Below is a form that looks exactly like the one above, except the first text box has its NAME attribute set to "griswald" and the second set to "ookook". Go ahead, try to put your name and email in. You'll get no help from AutoComplete.
You didn't get any help because you don't have VCARD_GRISWALD or VCARD_OOKOOK on your computer. Luckily, I didn't give you the opportunity to submit the form, or you would have.
Basically, the *vcard_name* attribute overrides the name attribute. It tells the browser to use the vcard_name value passed as the schema to look for AutoComplete suggestions. If this is not provided, the name attribute is used.
Specifies the vCard type to use for the Autocomplete box. Setting the
value of the vCard_name attribute causes the contents of the
Autocomplete window to depend on the value of this attribute only,
regardless of the value of the name attribute. If the value of the
vCard_name attribute is not specified, the contents of the
Autocomplete window depend on the value of the name attribute.
Source : http://help.dottoro.com/lhwgvcmt.php

Clear input values

Data comes from a Servlet to HTML input field in a JSP page. When I press <input type="reset">, the data is not cleared. How can I solve this?
HTML reset buttons do not clear the fields in the form; they reset the fields back to their initial values (see example).
If you want to actually clear the data, you'll need to write a specific server-side controller to do that, or use javascript.