Pen Settings



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


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


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.


                <div ng-app="app">
  <div ng-controller="UploadController as vm">
    <div class="container">
      <div class="page-header">
        <h1>Angular file upload directive</h1>
        <h6>A simple directive to create a customizable file input control.</h6>

      <div class="alert alert-info">
        Don't forget to display the console in CodePen to see the uploaded file !

      <form ng-model="vm.file" my-file-upload>
        <div class="form-group">
          <label for="fileName">Select a file</label>
          <div class="input-group">
            <input type="text" id="fileName" class="form-control" readonly ng-model="fileName" ng-click="browse()">
            <span class="input-group-btn">
              <button type="button" class="btn btn-default" ng-click="browse()">Browse</button>

          <button type="reset" class="btn btn-default" ng-click="reset()">Reset</button>
          <button type="button" class="btn btn-primary" ng-click="vm.upload()" ng-disabled="!vm.file">Upload</button>





                var app = angular.module("app", ["myDirectives"]);
var myDirectives = angular.module("myDirectives", []);

app.controller("UploadController", function ($log) {
  this.upload = function () {
    $"Uploading:", this.file || "no file selected!");

myDirectives.directive("myFileUpload", function ($compile) {
  return {
    restrict: "AE",
    require: "ngModel",
    scope: true,
    link: link

  function link (scope, element, attrs, ngModel) {
    var input = angular.element("<input type=\"file\" style=\"display: none;\">");

    input.bind("browse", function () {;
    input.bind("change", function (changed) {
      if ( < 1) {

      var fileName =[0].name;
      var reader = new FileReader();

      reader.onload = function (loaded) {
        scope.fileName = fileName;


    scope.browse = function () {
    scope.reset = function () {
      scope.fileName = null;