-3

I have been working on my website and cant for the love of god find a way to actualy do this. I tried with but i cant get the picture to upload to my site. I dont know how to acess the information thats in the input. Is it even possible?

  • 1
    We have no idea what you are asking. Please add more details and code to your question. Are you asking how a user can upload a image? – epascarello Dec 02 '19 at 14:37
  • sure. It is possible and I can reveal you a secret about that! Google holds tons of possible hints on how to do it – Lelio Faieta Dec 02 '19 at 14:38
  • I am sorry i am a newbie. I dont have much of code but i can explain more is in my html and i want the picture thats uloaded to be in my inner html so its basicly like when you submit a picture in for example facebook. Does that make sence? – Gr0mash Dec 02 '19 at 14:42
  • https://www.webtrickshome.com/faq/how-to-display-uploaded-image-in-html-using-javascript – Med Elgarnaoui Dec 02 '19 at 14:45
  • Your question needs to be more objective. You should look for a tutorial on what you want to do. – Everson Rafael Dec 02 '19 at 14:50
  • You must give us more details so we can try to help – Med Elgarnaoui Dec 02 '19 at 14:50

2 Answers2

1

Are you wanting to upload a picture to your website. Or are you looking for a form that lets a user upload an image?.

I would recommend checking out this link - https://www.w3schools.com/html/html_images.asp.

W3schools have lots of good tutorials for beginners when it comes to HTML and CSS.

How to make a simple image upload using Javascript/HTML. If you want a user to do it then it has already been answered on here see link.

FYI. When asking questions on here try to be as specific as possible. Include snippets of your code etc. General questions can be difficult to answer :)

Deeroy
  • 221
  • 2
  • 13
1

A simple google would of answered this question but you need to do the following.

<input type='file' />
<br><img id="myImg" src="#" alt="your image" height=200 width=100>

Javascript here -

window.addEventListener('load', function() {
  document.querySelector('input[type="file"]').addEventListener('change', function() {
      if (this.files && this.files[0]) {
          var img = document.querySelector('img');  // $('img')[0]
          img.src = URL.createObjectURL(this.files[0]); // set src to blob url
          img.onload = imageIsLoaded;
      }
  });
});

function imageIsLoaded() { 
  alert(this.src);  // blob url
  // update width and height ...
}


Hughesey
  • 155
  • 12