Første fejl selv fundet.
test.php
Line 11: watermark_image($file_tmp, 'images/uploads/'.);
Rettet til: watermark_image($file_tmp, 'images/uploads/'.$file_name);
1: Nu fejlmelder den hvis man forsøger at uploade uden et accepteret type.
2: Nu fejler den i upload med korrekt type.
Blank side.
Så nu er det test_funk.php der er problemer med.
Fandt frem til en fejl et sted i test_funk.php
- <?php
- function allowed_image($file_name) {
- $allowed_ext = array('jpg', 'jpeg', 'png', 'gif');
- $file_ext = end(explode('.', $file_name));
-
- return (in_array($file_ext, $allowed_ext) == true) ? true : false;
- }
-
- function watermark_image($file, $destination) {
- $watermark = imagecreatefrompng('testup/watermark.png');
-
-
- }
- ?>
Det her skal ind i det. Men fejler..
- $source = getimagesize($file);
- $source_mime = $source('mime');
-
- if ($source_mime == 'image/png') {
- $image = imagecreatefrompng($file);
- } else if ($source_mime == 'image/jpeg') {
- $image = imagecreatefromjpeg($file);
- } else if ($source_mime == 'image/gif') {
- $image = imagecreatefromgif($file);
- }
-
- imagecopy($image, $watermark, 10, 10, 0, 0, imagesx($watermark), imagesy($watermark));
- imagepng($image, $destination);
Altså komplet:
- <?php
- function allowed_image($file_name) {
- $allowed_ext = array('jpg', 'jpeg', 'png', 'gif');
- $file_ext = end(explode('.', $file_name));
-
- return (in_array($file_ext, $allowed_ext) == true) ? true : false;
- }
-
- function watermark_image($file, $destination) {
- $watermark = imagecreatefrompng('testup/watermark.png');
-
- $source = getimagesize($file);
- $source_mime = $source('mime');
-
- if ($source_mime == 'image/png') {
- $image = imagecreatefrompng($file);
- } else if ($source_mime == 'image/jpeg') {
- $image = imagecreatefromjpeg($file);
- } else if ($source_mime == 'image/gif') {
- $image = imagecreatefromgif($file);
- }
-
- imagecopy($image, $watermark, 10, 10, 0, 0, imagesx($watermark), imagesy($watermark));
- imagepng($image, $destination);
- }
- ?>
Fra line 12 til 24.
Indlæg senest redigeret d. 27.09.2013 02:04 af Bruger #17554