VIPbanner_de
www.VIPbanner.de
- 1 Mai 2006
- 2.598
- 150
hallo,
ich arbeite grad an userprofilen und würde gerne alternativ zu einem profilbild mittels http pfad eine uploadfunktion anbieten.. Jetzt habe ich im web ein script gefunden das ich noch nach meinen Wünschen angepasst habe.. allerdings funktioniert das nicht..
Jetzt habe ich PHP 5 und Register Globals auf ON.
$filename = $userfile_name;
$filetype = $userfile_type;
$filetmp = $userfile_tmp_name;
Gibt jeweils NICHTS aus.. auch nicht wenn ich es wie folgt mache:
$filename = $HTTP_POST_FILES['pic_file']['name'];
$filetype = $HTTP_POST_FILES['pic_file']['type'];
$filetmp = $HTTP_POST_FILES['pic_file']['tmp_name'];
Woran liegt das?!
na auf.. wo sind unsere Superhirne?!? *ZuHacker&COschiel*
ich arbeite grad an userprofilen und würde gerne alternativ zu einem profilbild mittels http pfad eine uploadfunktion anbieten.. Jetzt habe ich im web ein script gefunden das ich noch nach meinen Wünschen angepasst habe.. allerdings funktioniert das nicht..
PHP:
<? if ($sendbild) { ?>
<form method="post" enctype="multipart/form-data" action="profil.php?sid=<?php echo $sid; ?>&userid=<?php echo $userid; ?>">
<input type="hidden" name="MAX_FILE_SIZE" value="4000000">
<input type="hidden" name="go" value="profileditcheck">
<br>
<strong>File Upload</strong> <br>
<br>
<input name="pic_file" type="file" size=40>
<br>
<br>
<input type="submit" name="uploadbild" value="Speichern">
</form>
<?
include("../templates/member-footer.txt");
die;}
if($uploadbild){
// --------------------------------
// Diverse Variablen
// --------------------------------
$path = "images/memberpics/"; // Url zum Speicherordner der großen Bilder
$thumb_path = "images/memberpics/thumb/"; // Url zum Speicherordner der Vorschaubilder
$config_width = "320"; // Bildbreite max. bei großem Bild
$config_height = "240"; // Bildhöhe max. bei großem Bild
$config_thumb_width = "80"; // Bildbreite max. bei Vorschaubild
$config_thumb_height = "60"; // Bildhöhe max. bei Vorschaubild
$resizequality = "70"; // Bildkompressionsrate 0-100
$deindomain = "https://www.bettertraffic.de/"; // unsere Domain
if ($userfile_name <> 'none')
{
// --------------------------------
// Get File Upload Info
// --------------------------------
$filename = $userfile_name;
$filetype = $userfile_type;
$filetmp = $userfile_temp_name;
// --------------------------------
// Check file type
// --------------------------------
switch ($filetype)
{
case 'image/jpeg':
case 'image/jpg':
case 'image/pjpeg':
$pic_filetype = '.jpg';
break;
case 'image/png':
case 'image/x-png':
$pic_filetype = '.png';
break;
case 'image/gif':
$pic_filetype = '.gif';
break;
default:
echo"Falsches Dateiformat. Nur JPEG, GIF oder PNG erlaubt!";
include("../templates/member-footer.txt");
die;
}
// --------------------------------
// Generate filename
// --------------------------------
srand((double)microtime()*1000000); // for older than version 4.2.0 of PHP
do
{
$pic_filename = md5(uniqid(rand())) . $pic_filetype;
}
while( file_exists($path . $pic_filename) );
// --------------------------------
// Move this file to upload directory
// --------------------------------
$ini_val = ( @phpversion() >= '4.0.0' ) ? 'ini_get' : 'get_cfg_var';
if ( @$ini_val('open_basedir') != '' )
{
if ( @phpversion() < '4.0.3' )
{
die("open_basedir is set and your PHP version does not allow move_uploaded_file<br /><br />Please contact your server admin");
}
$move_file = 'move_uploaded_file';
}
else
{
$move_file = 'copy';
}
$move_file($filetmp, $path . $pic_filename);
@chmod($path . $pic_filename, 0777);
// --------------------------------
// Well, it's an image. Check its image size
// --------------------------------
$pic_size = getimagesize($path . $pic_filename);
$pic_width = $pic_size[0];
$pic_height = $pic_size[1];
// --------------------------------
// This image is okay, we can cache its thumbnail now
// --------------------------------
if($pic_filetype != '.gif')
{
$gd_errored = FALSE;
switch ($pic_filetype)
{
case '.jpg':
$read_function = 'imagecreatefromjpeg';
break;
case '.png':
$read_function = 'imagecreatefrompng';
break;
}
$src = @$read_function($path . $pic_filename);
if (!$src)
{
$gd_errored = TRUE;
$pic_thumbnail = '';
}
else if( ($pic_width > $config_thumb_width) or ($pic_height > $config_thumb_height) )
{
// Resize it
if ($pic_width > $pic_height)
{
$thumbnail_width = $config_thumb_width;
$thumbnail_height = $config_thumb_width * ($pic_height/$pic_width);
}
else
{
$thumbnail_height = $config_thumb_height;
$thumbnail_width = $config_thumb_height * ($pic_width/$pic_height);
}
$thumbnail = @imagecreatetruecolor($thumbnail_width, $thumbnail_height);
$resize_function = 'imagecopyresampled';
@$resize_function($thumbnail, $src, 0, 0, 0, 0, $thumbnail_width, $thumbnail_height, $pic_width, $pic_height);
}
else
{
$thumbnail = $src;
}
if (!$gd_errored)
{
$pic_thumbnail = $pic_filename;
// Write to disk
switch ($pic_filetype)
{
case '.jpg':
@imagejpeg($thumbnail, $thumb_path . $pic_thumbnail, $resizequality);
break;
case '.png':
@imagepng($thumbnail, $thumb_path . $pic_thumbnail);
break;
}
@chmod($thumb_path . $pic_thumbnail, 0777);
} // End IF $gd_errored
} // End Thumbnail Cache
// --------------------------------------
// OK lets resize the original picture
// --------------------------------------
if($pic_filetype != '.gif')
{
$gd_errored = FALSE;
switch ($pic_filetype)
{
case '.jpg':
$read_function = 'imagecreatefromjpeg';
break;
case '.png':
$read_function = 'imagecreatefrompng';
break;
}
$src = @$read_function($path . $pic_filename);
if (!$src)
{
$gd_errored = TRUE;
$pic_resize = '';
}
else if( ($pic_width > $config_width) or ($pic_height > $config_height) )
{
// Resize it
if ( (($pic_width / $pic_height) > ($config_width / $config_height)) )
{
$resize_width = $config_width;
$resize_height = $config_width * ($pic_height/$pic_width);
}
else
{
$resize_height = $config_height;
$resize_width = $config_height * ($pic_width/$pic_height);
}
$resize = @imagecreatetruecolor($resize_width, $resize_height);
$resize_function = 'imagecopyresampled';
@$resize_function($resize, $src, 0, 0, 0, 0, $resize_width, $resize_height, $pic_width, $pic_height);
}
else
{
$resize = $src;
}
if (!$gd_errored)
{
$pic_resize = $pic_filename;
// Write to disk
switch ($pic_filetype)
{
case '.jpg':
@imagejpeg($resize, $path . $pic_resize, $resizequality);
break;
case '.png':
@imagepng($resize, $path . $pic_resize);
break;
}
@chmod($path . $pic_resize, 0777);
} // End IF $gd_errored
} // End Picture Resize
echo "Datei ist auf dem Server! <br><br>";
echo "Url des großen Bildes: <a href=\"$deindomain$path$pic_filename\" target=\"_blank\">".$deindomain.$path.$pic_filename;
echo "</a> <br><img src=\"$deindomain$path$pic_filename\"><br><br>";
echo "Url des Vorschaubildes: <a href=\"$deindomain$thumb_path$pic_filename\" target=\"_blank\">".$deindomain.$thumb_path.$pic_filename;
echo "</a> <br><img src=\"$deindomain$thumb_path$pic_filename\">";
}
include("../templates/member-footer.txt");
die;}
$filename = $userfile_name;
$filetype = $userfile_type;
$filetmp = $userfile_tmp_name;
Gibt jeweils NICHTS aus.. auch nicht wenn ich es wie folgt mache:
$filename = $HTTP_POST_FILES['pic_file']['name'];
$filetype = $HTTP_POST_FILES['pic_file']['type'];
$filetmp = $HTTP_POST_FILES['pic_file']['tmp_name'];
Woran liegt das?!
na auf.. wo sind unsere Superhirne?!? *ZuHacker&COschiel*