sto provando a creare dei thumbnails dopo che l'utente invia le sue immagini in rete.
ho trovato una funzione qui sul sito:
Codice PHP:
<?php
/************************************************************\
*
* Basic Thumbnail Generator Copyright 2007 Derek Harvey
* www.lotsofcode.com
*
* This file is part of Basic Thumbnail Generator.
*
* Basic Thumbnail Generator is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Basic Thumbnail Generator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Basic Thumbnail Generator; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
\************************************************************/
require_once 'thumbnail.class.php';
$thumbnail = new thumbnail;
if (!empty($_REQUEST['submit']))
{
$tmp = $_FILES['uploaded_file']['tmp_name'];
$org = $_FILES['uploaded_file']['name'];
if ($tmp)
{
$directory = 'uploads'; // Upload files to here.
$prefix = 'uploaded_'; // Filename prefixes
// Upload all image files
$lrgImage = $thumbnail->generate($tmp, $org, $directory, $prefix.'lrg', 300); // large file
$medImage = $thumbnail->generate($tmp, $org, $directory, $prefix.'med', 200); // medium file
$smlImage = $thumbnail->generate($tmp, $org, $directory, $prefix.'sml', 100); // small file
if ($smlImage && $medImage && $lrgImage) // If all files are ok
{
$info = '
<fieldset>
<legend>Files uploaded successfully</legend>
<img src="'.$lrgImage.'">
<img src="'.$medImage.'">
<img src="'.$smlImage.'">
</fieldset><br />
';
}
}
else
{
$info = '<p>No file selected</p>';
}
}
?>
che richiamo in un'altra pagina:
Codice PHP:
require_once('thumbnail.class.php');
$t = $_FILES["file$k"]['tmp_name'];
$sz = $_FILES["file$k"]['size'];
$n = $_FILES["file$k"]['name'];
$dest = "../img/immagini/";
$smlImage = $thumbnail->generate($t, $n, $dest."/TB", 'TB_'.$n, 100);
ma ricevo questo messaggio di errore: Fatal error: Call to a member function on a non-object in C:\WM\www\galleria\spt\add_imgs.php on line 50
mi sapete spiegare dove sbaglio?
grazie.