2016-09-22 74 views
0

我使用PHP文件附件上传文件。在数据库中,我获取文件的扩展名并将其存储到数据库中。 有修改按钮可以从数据库中获取所有条目并显示在屏幕上。有一个文本字段和一个文件类型字段。如何自动附加文件到数据库输入文件类型字段

现在的问题是我无法将文件设置为文件类型字段,所以请在此帮助我。

在此先感谢。

回答

0

,因为你还没有提供任何代码示例,它很难确定什么发出你有,但我的猜测是你在寻找这样的事情

<input type="file" id="file" name="file"/> 
<button ng-click="add()">Add</button> 

及获取文件的内容使用下面的代码

$scope.add = function(){ 
    var f = document.getElementById('file').files[0], 
    r = new FileReader(); 
    r.onloadend = function(e){ 
    var data = e.target.result; 
    //send your binary data via $http or $resource or do anything else with it 
} 
r.readAsBinaryString(f); 
} 

更多的信息检查这个链接enter link description here

相关问题