Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <form id="upload-form">
    <input type="file" id="file-select-input" multiple />
    <button id="upload-button">Upload</button>
</form>
              
            
!

CSS

              
                
              
            
!

JS

              
                function supportAjaxUploadWithProgress() {
  return supportFileAPI() && supportAjaxUploadProgressEvents() && supportFormData();

  function supportFileAPI() {
    var fi = document.createElement('INPUT');
    fi.type = 'file';
    return 'files' in fi;
  };

  function supportAjaxUploadProgressEvents() {
    var xhr = new XMLHttpRequest();
    return !! (xhr && ('upload' in xhr) && ('onprogress' in xhr.upload));
  };

  function supportFormData() {
    return !! window.FormData;
  }
}

var form = document.getElementById('upload-form');
var fileSelect = document.getElementById('file-select-input');
var uploadButton = document.getElementById('upload-button');

form.onsubmit = function(event) {
  // Prevent a non-AJAX file upload from starting
  event.preventDefault();

  // Let the user know that the upload has begun
  uploadButton.innerHTML = 'Uploading...';

  // Get the selected files from the input
  var files = fileSelect.files;
  
  // Create a new FormData object
  var formData = new FormData();
  
  // Loop through each of the selected files.
  for(var i = 0; i < files.length; i++){
    var file = files[i];
    // Check the file type
    if (!/image.*/.test(file.type)) {
      return;
    }

    // Add the file to the form's data
    formData.append('photos[]', file, file.name);
  }
  
  // Set up the request object
  var xhr = new XMLHttpRequest();
  
  // Open the connection and pass the file name
  xhr.open('POST', 'handler.php', true);
  
  // Set up a handler for when the request finishes
  xhr.onload = function () {
    uploadButton.innerHTML = 'Upload';
    if (xhr.status === 200) {
      // File(s) uploaded
      alert('File uploaded successfully');
    } else {
      alert('Something went wrong uploading the file.');
    }
  };
  
  xhr.send(formData);
}
              
            
!
999px

Console