Last active
August 29, 2015 13:56
-
-
Save mgcdanny/9054791 to your computer and use it in GitHub Desktop.
File Upload with User Generated Metadata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.setFile = function (element) { | |
$scope.upFile = element.files[0]; | |
} | |
$scope.uploadAll = function(){ | |
formData = new FormData() | |
formData.append("upFileTitle",$scope.upFileTitle) | |
formData.append("upFileDesc",$scope.upFileDesc) | |
formData.append("upFile",$scope.upFile) | |
$http.post("/api/upload", formData, { | |
headers: { 'Content-Type': undefined }, | |
transformRequest: angular.identity | |
}).success(function(){ | |
getAllTables() | |
}); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1> Upload Your Data (CSV Only) </h1> | |
<form role="form" method="post" name="formData"> | |
<input type="file" onchange="angular.element(this).scope().setFile(this)" ng-model="upFileDisplayName"/> | |
<input type="text" ng-model="upFileTitle" placeholder="Type The Title"/> | |
<textarea ng-model="upFileDesc" placeholder="Type Description"> </textarea> | |
<button ng-click='uploadAll()' type="submit" class="btn btn-default">Submit</button> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/api/upload', methods=['POST']) | |
def upload_file(): | |
theFile = request.files['upFile'] | |
theTitle = request.form['upFileTitle'] #user generated title | |
theDescription = request.form['upFileDesc'] #user generated description of the file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment