問題:
Here is my HTML form:這是我的 HTML 表單:
<form name="myForm" ng-submit="">
<input ng-model='file' type="file"/>
<input type="submit" value='Submit'/>
</form>
I want to upload an image from local machine and want to read the content of the uploaded file.我想從本地機器上傳圖像並想讀取上傳文件的內容。 All this I want to do using AngularJS.所有這些我都想使用 AngularJS 來完成。
When I try to print the value of $scope.file
it comes as undefined.當我嘗試打印$scope.file
的值時,它是未定義的。
解決方案:
參考一: https://stackoom.com/question/1FvAH參考二: File Upload using AngularJS