cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


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.

              <body class="container" ng-app="app" ng-controller="DemoCtrl">
  <h2>Backand Simple Upload File</h2>
  <h4>Explore Backand File functioanlity by upload or delete a file</h4>
  <form role="form" name="uploadForm">
    <div class="row">
        <img ng-src="{{imageUrl}}" ng-if="imageUrl"/>
        <input id="fileInput" type="file" accept="*/*" ng-model="filename" />
        <input type="button" value="x" class="delete-file" title="Delete file" ng-disabled="!imageUrl" ng-click="deleteFile()" />
      <p ng-if="imageUrl">Image URL = {{imageUrl}}</p>
  To use this example with your app follow these steps
        Set your app name and security token in the config:
myApp.config(function(BackandProvider) {
   // enter your app name here
   BackandProvider.setAppName('your app name here');
   // enter your app anonymous token here
   BackandProvider.setAnonymousToken('your app anonymous token here');
    Create a server side action in Backand<br>
    by going into the items object actions tab<br> 
    and clicking on the Back& Files icon.<br>
    Name your action "files"<br>
  width: 220px;
              var myApp = angular.module('app', ['backand']);

// Backand security configuration for your app
myApp.config(function(BackandProvider) {
  // enter your app name here
  // enter your app anonymous token here

myApp.controller('DemoCtrl', ['$scope', 'Backand', DemoCtrl]);

function DemoCtrl($scope, Backand) {

  // Create a server side action in backand
  // Go to any object's actions tab 
  // and click on the Backand Storage icon.
  // Backand consts:
  var objectName = 'todo';
  var filesActionName = 'files';
  // Display the image after upload
  $scope.imageUrl = null;
  // Store the file name after upload to be used for delete
  $scope.filename = null;
  document.getElementById('fileInput').addEventListener("change", function () {
    var file    = document.querySelector('input[type=file]').files[0];
    var reader  = new FileReader();

    reader.addEventListener("load", function () {
      // console.log(file);
      // console.log(reader);
      Backand.file.upload(objectName, filesActionName, file.name, reader.result)
      .then(function (response) {
        $scope.imageUrl = response.data.url;
        $scope.filename = file.name;
    }, false);

    if (file) {
  }, false);

  $scope.deleteFile = function(){
    if (!$scope.filename){
      alert('Please choose a file');
    // By calling the files action with DELETE method in will perform 
    // a deletion of the file from Backand Storage
    return Backand.file.remove(objectName, filesActionName, $scope.filename).then(function(res){
      // Reset the form
      $scope.imageUrl = null;
      document.getElementById('fileInput').value = "";
  $scope.initCtrl = function() {

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................