透かしを挿入する機能を追加すると、画像アップロードスクリプトがあり、BPODまたは500内部サーバーエラーが発生し始めました:(
私はこのことを解決しようとして午前中を費やしましたが、結果はありませんでした。私はその多くのコードを知っていますが、助けに感謝します:
<?php
//connect
include_once('connect.php');
$storage = 'store/';
$filename = htmlentities(isset($_FILES["file"]["name"]) ? $_FILES["file"]["name"] : '', ENT_QUOTES);
$podpis = htmlentities(isset($_POST['podpis']) ? $_POST['podpis'] : '', ENT_QUOTES);
$nick = htmlentities(isset($_POST['nick']) ? $_POST['nick'] : '', ENT_QUOTES);
if(isset($_FILES['file'])) {
$errors = array();
$maxsize = 2097152;
$acceptable = array(
'image/jpeg',
'image/jpg',
'image/gif',
'image/png'
);
if(($_FILES['file']['size'] >= $maxsize) || ($_FILES["file"]["size"] == 0)) $errors[] = 'Plik za duży. Dopuszczalny max. rozmiar = 2MB. ';
if(!in_array($_FILES['file']['type'], $acceptable) && (!empty($_FILES["file"]["type"]))) $errors[] = 'Plik zabroniony. Dopuszczalne pliki: JPG, GIF i PNG. ';
if (file_exists("store/" . $filename)) {
$filename = explode(".", $filename);;
$filename = rand(1, 100) . $filename[0] . "." . $filename[1];
}
$filename = str_replace(" ", "_", $filename);
if(count($errors) !== 0) {
foreach($errors as $error) echo $error;
die();
}
if ( $_FILES['file']['type'] !== 'image/gif' ) {
move_uploaded_file($_FILES["file"]["tmp_name"], $storage . $filename);
if ( $_FILES['file']['type'] == 'image/jpeg' || $_FILES['file']['type'] == 'image/jpg' )
$im = imagecreatefromjpeg("$storage/$filename");
$stamp = imagecreatefrompng('stamp.png');
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);
// Copy the stamp image onto our photo using the margin offsets and the photo
// width to calculate positioning of the stamp.
imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
// Output and free memory
header('Content-type: image/png');
imagepng($storage . $im);
imagedestroy($im);
$query = "INSERT INTO demoty (filename, title, nick, czas, upy) VALUES ('$im', '$podpis', '$nick', '$czas', 0)";
} else {
move_uploaded_file($_FILES["file"]["tmp_name"], $storage . $filename);
$query = "INSERT INTO demoty (filename, title, nick, czas, upy) VALUES ('$filename', '$podpis', '$nick', '$czas', 0)";
}
$czas = date('d-m-y G:H');
mysql_query($query) or die('connect error 4');
#echo '<script type="text/javascript">window.location = "index.php?page=0"</script>';
}