Hello, there is a script for uploading images to the server, it works, but when I want to upload another copy of such pictures in a reduced form, it fails to load only regular images, I will lay out the entire script, and a part how I want to get a smaller copy, thanks in advance for your help.
$img_width = imageSX($_FILES["file"]["name"][$key]); $img_height = imageSY($_FILES["file"]["name"][$key]); $k = round($img_width/IMG_WIDTH,2); $img_mini_width = round($img_width/$k); $img_mini_height = round($img_height/$k); $img_dest_id = imagecreatetruecolor($img_mini_width, $img_mini_height); $mini = 'img'; $result = imagecopyresampled($img_dest_id, $img_id, 0, 0, 0, 0, $img_mini_width, $img_mini_height ); $mini = 'img/'; $img = imagejpeg($img_dest_id, $mini/$name, 100); and the whole script
<?php require_once( $_SERVER['DOCUMENT_ROOT'] . '/registration/1/my_room/php/session.php'); require_once( $_SERVER['DOCUMENT_ROOT'] . '/bd.php'); header('Content-Type: application/json; charset=utf-8'); if(isset($_FILES)) { //ΠΏΡΠΎΠ»ΠΈΡΡΡΠ²Π°Π΅ΠΌ Π²Π΅ΡΡ ΠΌΠ°ΡΡΠΈΠ² ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠΉ ΠΏΠΎ ΠΎΠ΄Π½ΠΎΠΌΡ $_FILES['file']['name'] as $k=>$v $error = array(); $success_list = []; $error_list = []; $uploads_dir = 'images/'; foreach ($_FILES['file']['error'] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["file"]["tmp_name"][$key]; $name = basename($_FILES["file"]["name"][$key]); $success = move_uploaded_file($tmp_name, "$uploads_dir/$name"); $img_width = imageSX($_FILES["file"]["name"][$key]); $img_height = imageSY($_FILES["file"]["name"][$key]); $k = round($img_width/IMG_WIDTH,2); $img_mini_width = round($img_width/$k); $img_mini_height = round($img_height/$k); $img_dest_id = imagecreatetruecolor($img_mini_width, $img_mini_height); $mini = 'img'; $result = imagecopyresampled($img_dest_id, $img_id, 0, 0, 0, 0, $img_mini_width, $img_mini_height ); $mini = 'img/'; $img = imagejpeg($img_dest_id, $mini/$name, 100); if ($success) { $success_list[] = $name; } else { $error_list[] = $name; } } else { $error_list[] = $_FILES['file']['name'][$key]; } } $error_list = implode(',', $error_list); $success_list = implode(',', $success_list); $sqlimage = "INSERT INTO images_big(login, catalog, filename) VALUES(:login, :catalog, :filename)"; $stmtimg = $pdo->prepare($sqlimage); $stmtimg->bindParam(':catalog', $uploads_dir, PDO::PARAM_STR); $stmtimg->bindParam(':filename', $success_list, PDO::PARAM_STR); $stmtimg->bindParam(':login', $_GET['login'], PDO::PARAM_STR); $stmtimg->execute(); } ?>