Current File : /home/users/barii/public_html/finansenl.com.pl/wodki/admin/tablice/upload4.php
<?php

// Count # of uploaded files in array
$total = count($_FILES['upload']['name']);

 
$directory = "img/dodatki/naklejki/";
$f = glob($directory . "*");
if ($f){
 $tot = count($f);
}

// Loop through each file
for($i=0; $i<$total; $i++) {
  //Get the temp file path
  $tmpFilePath = $_FILES['upload']['tmp_name'][$i];

  if (strpos($_FILES['upload']['name'][$i], '.jpg') !== false) { $roz = '.jpg';}
  elseif (strpos($_FILES['upload']['name'][$i], '.png') !== false) {$roz = '.png';}

  //Make sure we have a filepath
  if ($tmpFilePath != ""){
    //Setup our new file path
    $newFilePath = "img/dodatki/naklejki/" .$_POST['motywykat']."--".($tot+$i)."$roz";
    if(move_uploaded_file($tmpFilePath, $newFilePath)) {
      make_thumb("https://www.etykietyweselne.pl/admin/tablice/img/dodatki/naklejki/" .$_POST['motywykat'].'--'.($tot+$i).$roz, 'img/mini/naklejki/'.$_POST['motywykat'].'--'.($tot+$i).$roz, 300);
      make_thumb("https://www.etykietyweselne.pl/admin/tablice/img/dodatki/naklejki/" .$_POST['motywykat'].'--'.($tot+$i).$roz, 'img/dodatki/naklejki/'.$_POST['motywykat'].'--'.($tot+$i).$roz, 800);
      echo "<p>Pliki wgrany</p>";
    }
  }
}
header("location: /admin.php");


function make_thumb($src, $dest, $desired_width) {

	/* read the source image */
	
  if (strpos($src, '.jpg') !== false) {
   $source_image = imagecreatefromjpeg($src);
  }
  elseif (strpos($src, '.png') !== false) {
   $source_image = imagecreatefrompng($src);
  }
	$width = imagesx($source_image);
	$height = imagesy($source_image);
         //echo $width;
	
	/* find the "desired height" of this thumbnail, relative to the desired width  */
	$desired_height = floor($height * ($desired_width / $width));
	
	/* create a new, "virtual" image */
	$virtual_image = imagecreatetruecolor($desired_width, $desired_height);        
        imagealphablending($virtual_image, FALSE);
        imagesavealpha($virtual_image, TRUE);
	
	/* copy source image at a resized size */
	imagecopyresampled($virtual_image, $source_image, 0, 0, 0, 0, $desired_width, $desired_height, $width, $height);
	
	/* create the physical thumbnail image to its destination */
  
  
  if (strpos($src, '.jpg') !== false) {
   @imagejpeg($virtual_image, $dest);
  }
  elseif (strpos($src, '.png') !== false) {
   @imagepng($virtual_image, $dest);
  }
	
}

?>