Answer the question
In order to leave comments, you need to log in
Why does the script not process all images?
Hi friends. There is a script that uploads images to a folder on the server and applies a "watermark".
Tell me why it does not process all the images?
<?php
$allowedExts = array("jpg", "jpeg", "gif", "png");
$pre_extension = explode(".", $_FILES["file"]["name"]);
$extension = end($pre_extension);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 3000000)
&& in_array($extension, $allowedExts)) {
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
} else {
$imageName = $_FILES["file"]["name"];
$uploaddir = '/newUpload/';
$uploadfile = getcwd().$uploaddir.basename($_FILES['file']['name']);
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
list($width, $height) = getimagesize('newUpload/'.$imageName);
if ($_FILES["file"]["type"] == "image/jpeg")
$img = imageCreateFromJPEG('newUpload/'.$imageName);
if ($_FILES["file"]["type"] == "image/png")
$img = imageCreateFromPNG('newUpload/'.$imageName);
if ($_FILES["file"]["type"] == "image/gif")
$img = imageCreateFromGIF('newUpload/'.$imageName);
$img_o = imageCreateTrueColor($width, $height);
imageCopyResampled($img_o, $img, 0, 0, 0, 0, $width, $height, $width, $height);
$myCount = $width/1000;
//настройки для надписи
$font = "fonts/jhv68mh7.ttf";
$imageText = "Текст";
$angle = rad2deg(atan2(imageSY($img_o), imageSX($img_o)));
//Цвета
$shadow = imageColorAllocateAlpha($img_o, 0, 0, 0, 50);
$color = imageColorAllocateAlpha($img_o, 252, 223, 159, 100);
imageTtfText($img_o, 100*$myCount, $angle, $width/2+3, $height/2+2, $shadow, $font, $imageText);
imageTtfText($img_o, 100*$myCount, $angle, $width/2, $height/2, $color, $font, $imageText);
if (file_exists("newUpload/" . $imageName)) {
header("Content-type: image/jpeg");
imageJPEG($img_o);
imageJPEG($img_o, "newUpload/" . $imageName, 100);
} else {
move_uploaded_file($_FILES["file"]["tmp_name"],
"newUpload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "newUpload/" . $_FILES["file"]["name"];
}
}
}
} else {
echo "Invalid file<br />";
print_r($_FILES);
}
?>
Answer the question
In order to leave comments, you need to log in
Well, for example, there is a file size limit of up to 3,000,000 bytes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question