【问题标题】:Angularjs get image and pass into PHPAngularjs获取图像并传递给PHP
【发布时间】:2016-06-22 16:21:15
【问题描述】:

我是 angularjs 领域的新手,所以我不明白如何做图片上传概念,

在注册表中,可以选择上传图片并输入个人详细信息。

我了解如何使用 angular-js 将详细信息传递给 php 文件,我在下面做了 喜欢

    var app = angular.module('angularPostPHP', []);
app.controller('regCtrl', function ($scope, $http) {
$scope.login = function () {
var request = $http({
    method: 'post',
    url:'http://localhost/HAP_testing/Registration.php',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
    data: {
        email: $scope.UserName,
        pass: $scope.FirstName
    }
});
/* Check whether the HTTP Request is successful or not. */
request.success(function (data) {
    alert("done"+data);
});

request.error(function(status)
{
 alert("Error"+status);
});
} });

但我们如何将用户选择的图像传递给服务,ng-model 选项仅适用于输入文件

帮我解决这个问题,谢谢提前。 如果你有任何参考链接和示例,请分享给我。

【问题讨论】:

  • 你甚至没有描述你的问题:\
  • 请搜索angular upload
  • 嗨 charlietfl,我想使用 angular 将图像传递到 php 文件中,是否有任何相关示例
  • ng-model 选项仅适用于您所说的输入文件...<input type="file" name="uploaded_files" size="40"> 这是一个输入字段...并在表单上使用:enctype="multipart/form-data"。 ..

标签: javascript php html angularjs


【解决方案1】:

您可以使用 base 64 格式上传您的图片。

链接:https://github.com/adonespitogo/angular-base64-upload

它将您的文件从文件格式转换为 base64 编码模型。你只需要在你的输入标签中指定这个指令。

<input type="file" ng-model="myfile" base-sixty-four-input>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-13
    • 2013-10-14
    相关资源
    最近更新 更多