0

I know that if I want to have a html field that let's the user upload a local file I can use

<input type="file"></input>

However, let's say I am guaranteed that all images will be at a valid absolute URL to an image. How do I let the user specify that? What input type do I use?

4

2 回答 2

0

You may have to use:

<input type="text"></input>

HTML5 has url input types:

<input type="url"></input>

Consult the MDN on inputs for more inforation.

于 2012-12-02T00:39:49.843 回答
0

If the user is just specifying a URL at which you can find the image, then all they're really entering is text. There's no input element that's specific for a URL.

<input type="text" />

What you do with that text is another story entirely. There's no way for the HTML to validate that it's a URL for an image, a valid URL, etc. That's all stuff you'd have to do in code.

于 2012-12-02T00:40:34.273 回答