Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 从Angularjs HTTP POST到PHP服务器页面的文本输入和图像文件数_Javascript_Php_Angularjs - Fatal编程技术网

Javascript 从Angularjs HTTP POST到PHP服务器页面的文本输入和图像文件数

Javascript 从Angularjs HTTP POST到PHP服务器页面的文本输入和图像文件数,javascript,php,angularjs,Javascript,Php,Angularjs,我正在使用$http从angularjs控制器向php服务器页面发布一些数据。我在将一个文本字段传递给一个图像文件时得到了结果,但我并没有得到第二个文本字段结果 我在下面展示了什么 HTML代码 <tr> <th>Year</th> <td><input type="text" ng-model="event_year" id="event_year" /></td> </tr> <tr&g

我正在使用$http从angularjs控制器向php服务器页面发布一些数据。我在将一个文本字段传递给一个图像文件时得到了结果,但我并没有得到第二个文本字段结果

我在下面展示了什么

HTML代码

<tr>
    <th>Year</th>
    <td><input type="text" ng-model="event_year" id="event_year" /></td>
</tr>
<tr>
    <th>Title</th>
    <td><input type="text" ng-model="title" id="title"/></td>
</tr>
<tr>
    <th>Image</th>
    <td><input type="file" file-model="myFile"/></td>
</tr>
<tr>
    <td><a href="#/home" style="text-decoration: none;"><input type="button" ng-model="cancel" value="Cancel"/></a></td>
    <td><button ng-click="uploadFile()">Submit</button></td>
</tr>
Php服务器页面

<?php

     $target_dir = "../images/";
     $name = $_POST['name'];
     //print_r($name);

     print_r($_FILES);
     $target_file = $target_dir . basename($_FILES["file"]["name"]);

     move_uploaded_file($_FILES["file"]["tmp_name"], $target_file);
     echo json_encode($_FILES["file"]); // new file uploaded
     //echo $name;

?>

文件已成功插入到文件夹中,但我没有使用angularjs中新的其他文本值。请帮忙。。非常感谢

<?php

     $target_dir = "../images/";
     $name = $_POST['name'];
     //print_r($name);

     print_r($_FILES);
     $target_file = $target_dir . basename($_FILES["file"]["name"]);

     move_uploaded_file($_FILES["file"]["tmp_name"], $target_file);
     echo json_encode($_FILES["file"]); // new file uploaded
     //echo $name;

?>