1

There are buttons like this:

 <p>
   Upload:<br>
  <br>
   <input type="file" name="datafile" size="40">
  </p>

Is it possible to have a button in which user can include (copy/paste) the url of a photo somewhere in the web?

Example: I want to have press button which will ask the user to insert a link of image from web like this and it will take the picture

5
  • What are you trying to do with this Dec 3, 2014 at 16:36
  • What are you using server side to process this? Dec 3, 2014 at 16:39
  • It's not clear to me what that means. Please elaborate.
    – isherwood
    Dec 3, 2014 at 16:39
  • by button, do you mean input field?
    – maRtin
    Dec 3, 2014 at 16:46
  • @Roi513 you mean to say that you want users to upload only images, right? If yes, this may interest you - stackoverflow.com/questions/9314164/…
    – srijan
    Dec 3, 2014 at 16:48

1 Answer 1

2

I understand that this is a vague answer, but it's only as vague as your question. If this is NOT what you want, please tell us what the end result should look like.

function writeImage(url){
  
  document.body.innerHTML = '<img src="' + url + '"/>';
  
  }
<input type="text" id="imgUrl" size="30" value="http://placekitten.com/g/300/200" placeholder="image url here"/><input type="button" value="Insert Image" onclick="writeImage(document.getElementById('imgUrl').value)"/>

Copy and paste this into a webpage:

    <input type="text" id="imgUrl" size="30" value="http://placekitten.com/g/300/200" placeholder="image url here"/><input type="button" value="Insert Image" onclick="writeImage(document.getElementById('imgUrl').value)"/>

<script>
function writeImage(url){

  var URL = url;

  var myWindow = window.open("", "_blank", "width=300, height=200");

myWindow.document.write("<img src='" + url + "'/>");

  }
</script>
2
  • Check my new code. Paste it into a webpage. Please upvote my answer if you think it works well. Dec 3, 2014 at 18:52
  • 1
    You might want to preload the image. In this example the image loads quickly but in some cases the image may take time to load and you might want to preload it with javascript. Ie. load the image then insert the html.
    – www139
    Dec 7, 2014 at 15:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.