PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Bräuchte ein PHP-Script....


Snatch
2004-11-18, 10:03:11
guten Tag,

ich suche ein Scipt, das ungefähr das gleiche macht wie http://img106.exs.cx

Also das Leute Bilder hochladen können, Thumbs erstellt werden und ein [ img] Code ausgegben wird zum Posten.
Ich möchte den Membern meines Forums gerne die Möglichkeit bieten Bilder hochzuladen und zu posten.

Kennt einer so ein Scipt ?

Gruß und danke
Snatch

mithrandir
2004-11-18, 16:02:51
Dere!

Ich hätte da ein Script zur Hand, wo ich ein Bild hochlade und einen Thumbnail generiere - vielleicht kannst du das ja erweitern/anpassen. Bitte nicht am Stil rumnörgeln ; - )

<?php
function write_thumbnail( $image_dir, $image_file )
{
$src_img = imagecreatefromjpeg("$image_dir/$image_file");

// Hier wird die Grösse für den Thumbnail eingestellt
if (imagesx($src_img) > imagesy($src_img))
{
$new_w = 120;
$new_h = imagesy($src_img) / imagesx($src_img) * 120;

}
else
{
$new_h = 145;
$new_w = imagesx($src_img) / imagesy($src_img) * 145;
}

if ( function_exists('imagecreatetruecolor') )
{
$dst_img = imagecreatetruecolor($new_w,$new_h);
}
else
{
$dst_img = imagecreate($new_w,$new_h);
}

imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,imagesx($src_img),ima gesy($src_img));
imagejpeg($dst_img, "$image_dir/t_$image_file");
}

function image_upload()
{
global $HTTP_POST_FILES, $HTTP_POST_VARS, $HTTP_GET_VARS;

$dir = "."; // im aktuellen Verzeichnis

if ( $HTTP_POST_FILES["screen"] )
{
$scr_tmp = $HTTP_POST_FILES['screen']['tmp_name'];
$scr_tgt = "img.jpg";
move_uploaded_file( $scr_tmp, $scr_tgt );

write_thumbnail( $dir, $scr_tgt );

echo "<a href=\"$dir/$scr_tgt\" target=\"blank\"><img src=\"$dir/t_$scr_tgt\" border=\"0\" /></a>";
}
}
?>

<html>
<head>
<title>File-Upload und PHP</title>
</head>
<body>
<p align="center">
<?php
image_upload();
?>
</p>
<p>Bilddateien hochladen und Thumbnail ablegen...</p>
<form method="post" enctype="multipart/form-data">
<table cellspacing="5">
<tr>
<td>Bild: </td>
<td><input type="file" name="screen"></td>
<td><input type="submit" value=" Upload "></td>
</tr>
</table>
</form>
</body>
</html>

bye, mith