Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>DOM documentation (Mozilla):</p> <blockquote> <p><code>element = document.getElementById(id);</code> </p> <p>where</p> <ul> <li><code>element</code> is a reference to an Element object, or null if an element with the specified ID is not in the document.</li> <li><code>id</code> is a case-sensitive string representing the unique ID of the element being sought.</li> </ul> </blockquote> <p>In your code <code>document.getElementById(id)</code> returns a single element and not a list.<br> To access the files added to the input take a look at the HTML5 Files API.</p> <pre><code>var f = (document.getElementById('img').files); for (var i =0; i &lt; f.length; i++){ var new_div = document.createElement('div'); new_div.innerHTML = f[i].name; document.body.appendChild(new_div); } </code></pre> <p>FYI: Using <code>document.write()</code> is extremely dangerous, and should be avoided. For more read this stackoverflow Q&amp;A: <a href="https://stackoverflow.com/questions/802854/why-is-document-write-considered-a-bad-practice">Why is document.write considered a &quot;bad practice&quot;?</a> </p> <p>In the example above I substituted <code>document.write</code> with <code>document.body.appendChild</code></p> <p><strong>Fiddle (with jQuery)</strong>: <a href="http://jsfiddle.net/4Yq4F/" rel="nofollow noreferrer">http://jsfiddle.net/4Yq4F/</a> <br><br></p> <h3>Getting the complete file path</h3> <p>This is in your response requesting for the complete file path of the files. Unfortunately due to security reasons this is <strong>not</strong> possible as of now. Mozilla Firefox browsers however will provide you with the complete file path with the <code>mozFullPath</code> attribute. If you want to use it, in the above example substitute <code>f[i].name</code> with <code>f[i].mozFullPath</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload