|
|
@@ -19,17 +19,26 @@
|
|
|
while (strlen($_POST["file_$total"]) > 0){
|
|
|
//$files[$total] = $_POST["file_$total"];
|
|
|
$img = $_POST["file_$total"];
|
|
|
+ error_log("FILE: " . $img);
|
|
|
//The next line wont work
|
|
|
- $img = str_replace('data:image/png;base64,', '', $img);
|
|
|
+ if (strpos($img, 'data:image/jpeg;base64,') < 10){
|
|
|
+ $ext = 'jpg';
|
|
|
+ $img = str_replace('data:image/jpeg;base64,', '', $img);
|
|
|
+ }
|
|
|
+ else if (strpos($img, 'data:image/png;base64,') < 10){
|
|
|
+ $ext = 'png';
|
|
|
+ $img = str_replace('data:image/png;base64,', '', $img);
|
|
|
+ }
|
|
|
$img = str_replace(' ', '+', $img);
|
|
|
//echo "IMG idx " . $total . ": " . $img . "<br/><br/><br/>br/><br/>";
|
|
|
$files[$total] = base64_decode($img);
|
|
|
+
|
|
|
//$file = 'image.png';
|
|
|
//$success = file_put_contents($file, $data);
|
|
|
$titles[$total] = mysqli_real_escape_string($con, $_POST["title_$total"]);
|
|
|
$descriptions[$total] = mysqli_real_escape_string($con, $_POST["description_$total"]);
|
|
|
//Save image to file
|
|
|
- $file = 'image.png';
|
|
|
+ $file = 'image.' . $ext;
|
|
|
$success = file_put_contents($file, $files[$total]);
|
|
|
$total ++;
|
|
|
}
|
|
|
@@ -49,12 +58,13 @@
|
|
|
$fname = "$id";
|
|
|
}
|
|
|
//Save image to file
|
|
|
- $file = "../img/galeria/$fname.png";
|
|
|
+ $file = "../img/galeria/$fname.$ext";
|
|
|
$success = file_put_contents($file, $files[$i]);
|
|
|
+ error_log("SUCCESS" . $success);
|
|
|
//Convert to jpg and create miniature and preview_image
|
|
|
//$im = new imagick("../img/galeria/$fname.png");
|
|
|
//$handle = fopen("../img/galeria/$fname.png", 'rb');
|
|
|
- $im = new Imagick("../img/galeria/$fname.png");
|
|
|
+ $im = new Imagick("../img/galeria/$fname.$ext");
|
|
|
//$im->readImageFile($handle);
|
|
|
$im->setImageBackgroundColor('white');
|
|
|
$im = $im->flattenImages();
|
|
|
@@ -71,7 +81,7 @@
|
|
|
$im->writeImage("../img/galeria/miniature/$fname.jpg");
|
|
|
$im->resizeImage(200, 0, Imagick::FILTER_POINT, true);
|
|
|
$im->resizeImage(0, 200, Imagick::FILTER_POINT, true);
|
|
|
- $im->writeImage("../img/galeria/t/$fname.jpg");
|
|
|
+ $im->writeImage("../img/galeria/thumb/$fname.jpg");
|
|
|
$im->clear();
|
|
|
$im->destroy();
|
|
|
//Delete initial png
|
|
|
@@ -82,6 +92,7 @@
|
|
|
$h = getimagesize("../img/galeria/$fname.jpg")[1];
|
|
|
//Entry in database
|
|
|
mysqli_query($con, "INSERT INTO photo (id, file, permalink, title_es, title_en, title_eu, description_es, description_en, description_eu, width, height, size, approved, username) VALUES ($id, '$fname.jpg', '$fname', '$titles[$i]', '$titles[$i]', '$titles[$i]', '$descriptions[$i]', '$descriptions[$i]', '$descriptions[$i]', $w, $h, $s, 0, '$username')");
|
|
|
+ error_log("INSERT INTO photo (id, file, permalink, title_es, title_en, title_eu, description_es, description_en, description_eu, width, height, size, approved, username) VALUES ($id, '$fname.jpg', '$fname', '$titles[$i]', '$titles[$i]', '$titles[$i]', '$descriptions[$i]', '$descriptions[$i]', '$descriptions[$i]', $w, $h, $s, 0, '$username')");
|
|
|
mysqli_query($con, "INSERT INTO photo_album VALUES ($id, $album);");
|
|
|
version();
|
|
|
$id ++;
|