Search
 
SCRIPT & CODE EXAMPLE
 

PHP

show uploaded image in php

//file_upload.php

  if(isset($_FILES['image'])){$errors= array();

  $file_name = $_FILES['image']['name'];

  $file_size = $_FILES['image']['size'];

  $file_tmp = $_FILES['image']['tmp_name'];

  $file_type = $_FILES['image']['type'];

  $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
  
  $extensions= array("jpeg","jpg","png");
  
  if(in_array($file_ext,$extensions)=== false){
     $errors[]="extension not allowed, please choose a JPEG or PNG file.";
  }
  
  if($file_size > 2097152) {
     $errors[]='File size must be excately 2 MB';
  }
  
  if(empty($errors)==true) {
     move_uploaded_file($file_tmp,"images/".$file_name);
     echo "Success";
  }else{
     print_r($errors);
  }    } ?>
Comment

PREVIOUS NEXT
Code Example
Php :: get page templete 
Php :: laravel db query log string replacements 
Php :: How to Get Radio Button Value in PHP Without Submit 
Php :: referencing constant in config laravel 
Php :: this php 
Php :: download file using jquery php 
Php :: yii2 migration --fields foreign 
Php :: date and time syntax 
Php :: php try catch non object 
Php :: php create html code 
Php :: laravel migration char length 
Php :: @method overide form laravel 
Php :: how to login first before see index php 
Php :: PHP OOP - Destructor 
Php :: guarded and fillable in laravel 
Php :: Form::select laravel 
Php :: Call to undefined method PsyUtilStr::random() 
Php :: Schema::defaultStringLength(199); 
Php :: rest api php 
Php :: acf get all checkbox options 
Php :: sort relation model count yii2 
Php :: debug bar laravel print array 
Php :: last index of array in laravel 
Php :: + php quantifer 
Php :: custom blade 
Php :: canany else 
Php :: php const scope 
Php :: php get day of week number 
Php :: remove php 
Php :: how to remove last element from php array 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =