Selbstextrahierende Datei-Erweiterung in PHP (Bild-upload-Skript)

Kann mir jemand sagen, was falsch ist mit diesem? Die Datei wird umbenannt, mit einem Zeitstempel, aber die Erweiterung nicht erhalten, extrahiert und in den neuen Namen.

    $filenameext = pathinfo($filename, PATHINFO_EXTENSION);

    $today = getdate();
    $uniqueStr = $today[year];
    $uniqueStr .= $today[mon];
    $uniqueStr .= $today[wday];
    $uniqueStr .= $today[mday];
    $uniqueStr .= $today[hours];
    $uniqueStr .= $today[minutes];
    $uniqueStr .= $today[seconds];

    $filename = $uniqueStr.".".$filenameext;

Der vollständige code:

<?php
$folder = 'images/';
$orig_w = 500;

if( isset($_POST['submit']) )
{
    $imageFile = $_FILES['image']['tmp_name'];
    $filenameext = pathinfo($filename, PATHINFO_EXTENSION);

    $today = getdate();
    $uniqueStr = $today[year];
    $uniqueStr .= $today[mon];
    $uniqueStr .= $today[wday];
    $uniqueStr .= $today[mday];
    $uniqueStr .= $today[hours];
    $uniqueStr .= $today[minutes];
    $uniqueStr .= $today[seconds];
    $filename = $uniqueStr.".".$filenameext;

    list($width, $height) = getimagesize($imageFile);

    $src = imagecreatefromjpeg($imageFile);
    $orig_h = ($height/$width)* $orig_w;

    $tmp = imagecreatetruecolor($orig_w, $orig_h);
    imagecopyresampled($tmp, $src, 0,0,0,0,$orig_w,$orig_h,$width,$height);
    imagejpeg($tmp, $folder.$filename,100);

    imagedestroy($tmp);
    imagedestroy($src);

    $filename = urlencode($filename);
    header("Location: crop.php?filename=$filename&height=$orig_h");
}

?>

InformationsquelleAutor | 2009-06-13
Schreibe einen Kommentar