sentite delle classi non capisco niente...e quindi della pillola su upload+resize... non ho capito niente, qualcuno sa dirmi come si include una classe e cosa è questo errore?
Fatal error: Cannot instantiate non-existent class: imageresized in d:\documenti\uni\2sem-3anno\basi di dati\heck\album_foto\pages\upload_1.php on line 107
Fatal error: Call to undefined function: imagecreatefromjpeg() in d:\documenti\uni\2sem-3anno\basi di dati\heck\album_foto\pages\upload_1.php(143) : eval()'d code on line 1
e poi... perchè al posto di eseguire il codice della classe me lo printa? non c'è nessun comando che gli dice di farlo.
ecco il contenuto della classe:
Codice PHP:
class ImageResized {
/**
* vars used to manage operations
*/
var $type, $img, $size, $dest, $name;
/**
* public constructor
* ImageResized( $imageToCopyResized, $newSize [, $destinationFolderToCreateResizedImage ] );
*/
function ImageResized( $img, $size, $dest = '' ) {
$this->img = &$img;
if( file_exists( $this->img ) == true ) {
$this->type = &UcFirst( strToLower( $this->__file_extension( $this->img ) ) );
$this->name = &substr( $this->img, 0, -( strLen( $this->type ) + 1 ) );
if( $this->type == 'Jpg' ) {
$this->type = 'Jpeg';
}
$this->size = &intVal( $size );
$this->dest = &str_replace( '//', '/', $dest.'/' );
$this->__createImage();
}
}
/**
* private method, called from constructor
* Check size to mantain aspect ratio, verify image type and show or create new resized image
* @param none no params need
* @return none headers with new image / create new image
*/
function __createImage() {
$imgSize = getimagesize( $this->img );
$imgX = $imgSize[0];
$imgY = $imgSize[1];
$newY = floor( ( $imgSize[1] * $this->size ) / $imgSize[0] );
eval( "\$img_original = imageCreateFrom{$this->type}( \"{$this->img}\" );" );
$img_final = imageCreateTrueColor( $this->size, $newY );
imageCopyResampled( $img_final, $img_original, 0, 0, 0, 0, $this->size, $newY, $imgX, $imgY );
if( $this->dest != '/' && is_Dir( $this->dest ) ) {
eval( "image{$this->type}( \$img_final, '{$this->dest}{$this->name}.".strToLower( $this->type )."', 100 );" );
}
else {
header( "Content-type: image/{$this->type}" );
eval( "image{$this->type}( \$img_final );" );
}
imageDestroy( $img_original );
imageDestroy( $img_final );
}
/**
* private method, called from constructor