简体   繁体   English

使用angular.js上传文件

[英]Upload files with angular.js

I have a page with some input fileds (like name, password and etc.). 我的页面上有一些输入字段(例如名称,密码等)。 Where the user click on submit, it loads all the fields to a file which located in the server. 用户单击提交时,它将所有字段加载到服务器中的文件中。

I want to create another field, which is input type for file, that upload the file with specific location 我想创建另一个字段,即文件的输入类型,该字段将文件上传到特定位置

Here is the relevant code 这是相关的代码

input filed: 输入字段:

<input type="text" name="arr" class="form-control" ng-model="arr['1']" required="">

input file form: 输入文件格式:

<input type="file" name="fileToUpload" id="fileToUpload">

The submit button: 提交按钮:

<button type="submit" style="float:center;" class="btn btn-primar" ng-click="submitForm(true)">Submit</button> 

submitForm is loaded the field to a specific file. SubmitForm会将字段加载到特定文件。

I have php script for upload files. 我有用于上传文件的php脚本。

My issue is that I want that when I'll click on submit, it will do both: upload the file and load all the fileds to specific file (execute the php file and the submitForm function). 我的问题是我希望当我单击“提交”时,它既可以执行以下操作:上传文件并将所有文件加载到特定文件(执行php文件和SubmitForm函数)。 In all the example I see, the upload process is a seprate process (with submit button for the specific file). 在我看到的所有示例中,上传过程都是一个单独的过程(带有针对特定文件的提交按钮)。

Maybe try using something like this . 也许尝试使用像这样 Might be helpful. 可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM