0

Recently, I had to write a simple uploader (reusable) using AngularJs, while, keeping my API in separate place and finally wrote one using blueimp jQuery File Uploader and made lil customizing it. I Thought it might be great to share this and hopefully improve myself in learning in AngularJs. (I've added the answer)

1
  • This is great, Is there a 'how do I' question that could be asked here, so that people discover it easier? Commented Nov 18, 2013 at 6:02

1 Answer 1

0

http://codelikeapoem.com/2013/05/angularjs-tutorial-4-file-upload-using.html (You can download the entire code their)

App.Coffee

@angTut = angular.module("angTut", ['LocalStorageModule', 'ngResource', 'uploaderComponent']);

@angTut.constant('uploadServiceUrl', 'http://192.168.0.2/api/index.php')

todos_uploader_controller.coffee

"use strict"
@angTut.controller('TodosUploadController', (
$scope, uploadService
) ->

$scope.uploadLayer = (e, data, process) ->
    $scope.uploadReturn = uploadService.process(e, data, process)
    $scope.uploadReturn = uploadService.initialize() 
)

uploader.directive

https://gist.github.com/sk8terboi87/5652187

upload.html

    <div class="control-group">
      <input id="testUpload" type="file" fileupload name="files[]" uploadurl="uploadReturn.uploadurl" done="uploadLayer(e, data, 'done')" fail="uploadLayer(e, data, 'fail')" progress="uploadLayer(e, data, 'progress')">
       <div class="well" ng-show="uploadReturn.status">
       {{uploadReturn.message}}
        <div ng-show="!uploadReturn.error">
            <p class="label label-info">File: {{uploadReturn.successData.name}}</p>
            <p><a href="{{uploadReturn.successData.fullUrl}}" target="_blank">View file</a></p>
        </div>
       </div>
   </div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.