“Hochgeladenes Bild in PHP anzeigen” Code-Antworten

IMG -Upload in PHP


                if(isset($_FILES['image']))
                {
                    $img_name = $_FILES['image']['name'];      //getting user uploaded name
                    $img_type = $_FILES['image']['type'];       //getting user uploaded img type
                    $tmp_name = $_FILES['image']['tmp_name'];   //this temporary name is used to save/move file in our folder.
                    
                    // let's explode image and get the last name(extension) like jpg, png
                    $img_explode = explode(".",$img_name);
                    $img_ext = end($img_explode);   //here we get the extension of an user uploaded img file

                    $extension= ['png','jpeg','jpg','gif']; //these are some valid img extension and we are store them in array.
                
kinjal suryavanshi

Hochgeladenes Bild in PHP anzeigen

//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);
  }    } ?>
Happy Hedgehog

Ähnliche Antworten wie “Hochgeladenes Bild in PHP anzeigen”

Fragen ähnlich wie “Hochgeladenes Bild in PHP anzeigen”

Weitere verwandte Antworten zu “Hochgeladenes Bild in PHP anzeigen” auf PHP

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen