Dönerman
27.09.2005, 09:59:54
Ich habe ein script gefunden wo man automatisch thumbs erstellen kann!
aber die *.gif werden schwarz! warum! könnt ihr mir helfen??
mein ganzes upload script!
<?php
include ("dbconnect.php");
$imgname = $_FILES['userfile']['name'];
$path = 'upload';
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
copy($_FILES['userfile']['tmp_name'], "./".$path."/$imgname");
header ("location: upload_3_admin1.php");
} else {
if (!$imgname) {
header ("location: upload_4_admin1.php");
}
}
$folder_scr = "upload";
$des_src = "thumbs";
$thumbx = "100";
$thumby = "100";
function mkthumb($img_src,
$img_width,
$img_height,
$folder_scr,
$des_src)
{
$image = imagecreatefromjpeg($folder_scr."/".$img_src);
list($src_width, $src_height) = getimagesize($folder_scr."/".$img_src);
if($src_width >= $src_height)
{
$new_image_width = $img_width;
$new_image_height = $src_height * $img_width / $src_width;
}
if($src_width < $src_height)
{
$new_image_height = $img_width;
$new_image_width = $src_width * $img_height / $src_height;
}
$new_image = imagecreatetruecolor($new_image_width, $new_image_height);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width,$new_image_height, $src_width, $src_height);
imagejpeg($new_image, $des_src."/".$img_src, 100);
}
$filename = $_SERVER['PHP_SELF'];
$verz=opendir($folder_scr);
$linkl = array ();
while ($file = readdir ($verz))
{
if($file != "." && $file != ".." && $file != $filename)
{
array_push ($linkl, "$file");
}
}
$anzahl = count($linkl);
sort ($linkl);
foreach($linkl as $key => $value)
{
if(!file_exists($des_src."/".$value))
{
mkthumb($value, $thumbx, $thumby, $folder_scr, $des_src);
}
}
closedir($verz);
$datum = date("j.n.Y g:i:s");
$eintrag = "INSERT INTO file (name, time) VALUES ('$imgname', '$datum')";
$eintragen = mysql_query($eintrag);
exec('xcopy C:\apachefriends\xampp\htdocs\test\php\echt\admin1\upload C:\apachefriends\xampp\htdocs\test\php\echt\admin1\picture /e/i');
header ("location: upload/index.php?id=$imgname");
aber die *.gif werden schwarz! warum! könnt ihr mir helfen??
mein ganzes upload script!
<?php
include ("dbconnect.php");
$imgname = $_FILES['userfile']['name'];
$path = 'upload';
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
copy($_FILES['userfile']['tmp_name'], "./".$path."/$imgname");
header ("location: upload_3_admin1.php");
} else {
if (!$imgname) {
header ("location: upload_4_admin1.php");
}
}
$folder_scr = "upload";
$des_src = "thumbs";
$thumbx = "100";
$thumby = "100";
function mkthumb($img_src,
$img_width,
$img_height,
$folder_scr,
$des_src)
{
$image = imagecreatefromjpeg($folder_scr."/".$img_src);
list($src_width, $src_height) = getimagesize($folder_scr."/".$img_src);
if($src_width >= $src_height)
{
$new_image_width = $img_width;
$new_image_height = $src_height * $img_width / $src_width;
}
if($src_width < $src_height)
{
$new_image_height = $img_width;
$new_image_width = $src_width * $img_height / $src_height;
}
$new_image = imagecreatetruecolor($new_image_width, $new_image_height);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_image_width,$new_image_height, $src_width, $src_height);
imagejpeg($new_image, $des_src."/".$img_src, 100);
}
$filename = $_SERVER['PHP_SELF'];
$verz=opendir($folder_scr);
$linkl = array ();
while ($file = readdir ($verz))
{
if($file != "." && $file != ".." && $file != $filename)
{
array_push ($linkl, "$file");
}
}
$anzahl = count($linkl);
sort ($linkl);
foreach($linkl as $key => $value)
{
if(!file_exists($des_src."/".$value))
{
mkthumb($value, $thumbx, $thumby, $folder_scr, $des_src);
}
}
closedir($verz);
$datum = date("j.n.Y g:i:s");
$eintrag = "INSERT INTO file (name, time) VALUES ('$imgname', '$datum')";
$eintragen = mysql_query($eintrag);
exec('xcopy C:\apachefriends\xampp\htdocs\test\php\echt\admin1\upload C:\apachefriends\xampp\htdocs\test\php\echt\admin1\picture /e/i');
header ("location: upload/index.php?id=$imgname");