title: How to upload file contents into variable Javascript/HTML?
body: <p>I'm making a script that uploads a script, or "payload" to a site with these steps:</p>
  
  <pre><code>1. User enters URL with * in place of query
  2. User selects payload, which is simply a file with a pre-written JS script.
  3. The * is replaced with the contents of the payload.
  4. The URL with a script replacing the query is opened in an iframe.
  </code></pre>
  
  <p>How would I do this? My main problem is the file-uploading-into-variable part. Here's my code so far:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;html&gt;
  
    &lt;head&gt;
  
      &lt;title&gt;Slingshot.XSS&lt;/title&gt;
  
    &lt;/head&gt;
  
    &lt;body style="font-family:monospace;" align="center"&gt;
  
      &lt;h2&gt;Slingshot.XSS&lt;/h2&gt;
      &lt;h3&gt;Slingshot.XSS is a script that launches pre-loaded XSS payloads at a target to test its vulnerabilities.&lt;/h3&gt;
      &lt;h4&gt;Please report all issues to &lt;a href="https://github.com/keeganjk/slingshot.xss/issues"&gt;&lt;/a&gt; or contact me at keeganjkuhn@gmail.com.&lt;/h4&gt;
      &lt;a href="github.com/keeganjk/slingshot.xss" style="font-family:monospace" align="center"&gt;Source Code / Learn More&lt;/a&gt;
      &lt;br /&gt;
  
      &lt;h4&gt;Enter a URL with &lt;b&gt;*&lt;/b&gt; in the place of query.&lt;/h4&gt;
      &lt;h5&gt;Example: https://www.google.com/#q=*&lt;/h5&gt;
      &lt;input type="text" id="myText" placeholder="Enter a URL"&gt; &lt;button onclick="myFunction()"&gt;Submit&lt;/button&gt;
      &lt;p id="demo"&gt;No Submitted URL&lt;/p&gt;
  
      &lt;h4&gt;Select a payload:&lt;/h4&gt;
      &lt;input type="text" id="myPayload" placeholder="Enter payload path"&gt; &lt;button onclick="selectPayload()"&gt;Submit&lt;/button&gt;
  
  
      &lt;script&gt;
  
        function myFunction() {
  
          var errors = [];
          var x = document.getElementById("myText").value;
  
          if ( !x.includes("http://") &amp;&amp; !x.includes("https://") ) {
  
            errors.push('missing HTTP or HTTPS in URL');
  
          }
  
          if (!x.includes("*")) {
  
            errors.push('missing * in place of query')
  
          }
  
          // Renders errors
          if (errors.length) {
  
             x = 'Error: ' + errors.join(', ') + '!'; 
  
          }
  
          document.getElementById("demo").innerHTML = x;
  
          }
  
        function selectPayload() {
  
  
  
        }
  
      &lt;/script&gt;
  
    &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>How would I let the user browse through files and then select one 
  and upload it to a variable?</p>