Current File : /home/users/barii/public_html/finansenl.com.pl/wodki/admin/tablice/upload3.php |
<?php
// Count # of uploaded files in array
$total = count($_FILES['upload']['name']);
// Loop through each file
for($i=0; $i<$total; $i++) {
//Get the temp file path
$tmpFilePath = $_FILES['upload']['tmp_name'][$i];
//Make sure we have a filepath
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "img/dodatki/ramki/" . $_FILES['upload']['name'][$i];
if(move_uploaded_file($tmpFilePath, $newFilePath)) {
make_thumb("https://www.etykietyweselne.pl/admin/tablice/img/dodatki/ramki/" .$_FILES['upload']['name'][$i], 'img/mini/ramki/'.$_FILES['upload']['name'][$i], 250);
make_thumb("https://www.etykietyweselne.pl/admin/tablice/img/dodatki/ramki/" .$_FILES['upload']['name'][$i], 'img/dodatki/ramki/'.$_FILES['upload']['name'][$i], 1184);
//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);
}
}
?>