AngularJS PHP Image Upload with preview Example

AngularJS PHP Image Upload with preview Example

In this Post We Will Explain About is File Upload Using AngularJS with php server script With Example and Demo.

Welcome on infinityknow.com – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to AngularJS – simple image upload with preview example in PHP

In this post we will show you Best way to implement javascript – Angularjs – File upload with php, hear for How to ng-file-upload for PHP Code Example with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

READ :  Angularjs Remove Table Row with Apply ngClassEven NgClassOdd

Your Example is latest source code to working on bellow listed simple file three things, we can see.

First of create a index.php
2)and then upload.php
3)images(images is a Folder, it should just on root path)

After this we can put code like as bellow, so let’s see bellow code

index.php



  <title>Step By Step Angularjs Image Uploading using PHP</title>
  <a href="http://angular.min.js">http://angular.min.js</a>



	<!-- live Form Start -->
	<form name="form" role="form">
	<!-- File Upload using AngularJS -->
	  

	  

	  <br />

	  <img style="width:400px">


	</form>

	<!--infinityknow.com Form End -->
	
	    var app =  angular.module('live-App',[]);
	    app.controller('liveCtrl', function($scope, $http) {
	      $scope.form = [];
	      $scope.data_files = [];
	      $scope.live_submit = function() {
	      	$scope.form.image = $scope.data_files[0];
	      	$http({
			  method  : 'POST',
			  url     : 'https://infinityknow.com/api/upload.php',
			  processData: false,
			  transformRequest: function (data) {
			      var live_formData = new FormData();
			      live_formData.append("image", $scope.form.image);  
			      return live_formData;  
			  },  
			  data : $scope.form,
			  headers: {
			         'Content-Type': undefined
			  }
		   }).success(function(data){
		        alert(data);
		   });
	      };
	      $scope.data_upload_data = function(params) {
		    $scope.currentFile = params.data_files[0];
		    var live_reader = new FileReader();
		    live_reader.onload = function(event) {
		      $scope.image_source = event.target.result
		      $scope.$apply(function($scope) {
		        $scope.data_files = params.data_files;

		      });

		    }
                    live_reader.readAsDataURL(params.data_files[0]);
		  }
	    });
	


upload.php

Example

READ :  AngularJS File-image Upload ng-file-upload | angular-file-upload

I hope you have Got Simple file upload example using AngularJS And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.

https://infinityknow.com – infinityknow is the most popular Programming & Web Development blog. Our mission is to provide the best online resources on programming and web development. We deliver the useful and best tutorials for web professionals — developers, programmers, freelancers and site owners. Any visitors of this site are free to browse our tutorials, live demos and download scripts.

Add a Comment

Your email address will not be published. Required fields are marked *