Newsgroup: it.comp.www.php
Titolo: Funzionalità Thumbnail a form upload...

Ciao a tutti...innanzitutto grazie per la vostra disponibilità alle mie
precedenti domande, spero anche io di poter dare presto risposte a qualcuno
:=)
poi passo alla domanda, come posso aggiungere a questo script di upload
immagini, la funzionalità di creare thumbnails tramite la gd library o cmq
il formato supportato da aruba?
Grazie e a presto
ZETA
<?
session_start();
include("../includes/commonfunctions.php");
newsfeed_getvariables('includes');
include("includes/adminfunctions.php");
$language = '../includes/languages/' . $newsfeed_variable[language] .
'.php';
include($language);
if ($newsfeed_userinfo[userid] != '') {
switch($newsfeed) {
case "do_upload":
do_upload($userfile, $userfile_name, $userfile_type, $userfile_size);
break;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
 <title>Files and Stuff</title>
 <link rel="STYLESHEET" type="text/css" href="style.css">
</head>
<? include ('includes/javabits.inc'); ?>
<body>
<script>
function send_file() {
if (theform.userfile.value.length == 0) {
alert ('Please select a file.')
theform.userfile.focus ()
return false
}
stuff.innerHTML='Uploading... This may take a while'
theform.send.value = 'Uploading...'
theform.submit()
return true
}
</script>
<form enctype="multipart/form-data" action="<? echo $PHP_SELF ?>"
method="post" name="theform">
<input type="hidden" name="MAX_FILE_SIZE" value="5000000">
<input type="hidden" name="newsfeed" value="do_upload">
<table width="98%" border="0" cellspacing="2" cellpadding="2"
align="center">
<tr class="titlebar">
<td>
Upload New file: <input name="userfile" type="file"> <input type="button"
name="send" value="Send File" onClick="send_file();">
</td>
</tr>
<tr class="odd">
<td id="stuff"><div align="center">Use this form to upload files.</div></td>
</tr>
</table>
</form>
<? list_files(); ?>
</body>
</html>
<? ###############################################################
#############################
#                           #
#      Upload Functions     #
#                           #
#############################
# <--- upload file ---> #
function do_upload($userfile, $userfile_name, $userfile_type,
$userfile_size) {
global $newsfeed_userinfo, $newsfeed_variable;
if ($newsfeed_userinfo[userLevel] > 0) {
newsfeed_dbconnect();
$dirname = "../uploads";
$filename = $newsfeed_userinfo[userid] . "_" . $userfile_name;
move_uploaded_file($userfile, $dirname."/".$filename) or die("<b>Error:</b>
could not copy file.");
if (ereg("image", $userfile_type)) {$type = 'image';}
else {$type = 'file';}
$query2 = "INSERT INTO $newsfeed_variable[filetable] VALUES('',
'$userfile_name', '$type', '$newsfeed_userinfo[userid]',
'$userfile_size','$filename')";
mysql_db_query($newsfeed_variable[dbname],$query2) or Die (mysql_error());
}
Header("Location: upload.php");
}
# <--- list files ---> #
function list_files() {
global $newsfeed_variable;
global $newsfeed_userinfo;
newsfeed_dbconnect();
# Do Images First
$query2 = "SELECT * FROM $newsfeed_variable[filetable] WHERE (filetype =
'image' and (fileOwner = '$newsfeed_userinfo[userid]' or fileOwner = '0') )
ORDER BY $newsfeed_variable[filetable].filename ASC";
$result = mysql($newsfeed_variable[dbname], $query2 );
$num = mysql_numrows($result);
if ($num != 0) { ?>
<table width="98%" border="0" cellspacing="2" cellpadding="2"
align="center">
<tr class="titlebar">
 <td colspan="4" class="titlebar">Available Images</td>
</tr>
<tr class="tableheader"><td>Image</td><td>File Names</td><td>File
Size</td><td>Add?</td></tr>
<?
$i = 0;
while ($i < $num) :
$theid = mysql_result($result,$i,"fileid");
$filename = mysql_result($result,$i,"filename");
$truename = mysql_result($result,$i,"filetruename");
$filesize = mysql_result($result,$i,"filesize");
$owner = mysql_result($result,$i,"fileowner");
if ($class == 'odd') {$class = 'even';}
else {$class = 'odd';}
#images
?>
<tr class="<? echo $class ?>">
<td><img src="../uploads/<? echo $truename ?>" width="60" height="60"
border="0" alt=""></td>
<td><? echo $filename; ?></td>
<td><? echo $filesize; ?></td>
<td><a href="javascript:fileadd('[image|<? echo $truename ?>|NONE]')"><img
src="images/icon.none.gif" width="24" height="24" alt="Insert Image"
border="0"></a>
<a href="javascript:fileadd('[image|<? echo $truename ?>|LEFT]')"><img
src="images/icon.left.gif" width="24" height="24" alt="Insert Image Aligned
Left" border="0"></a>
<a href="javascript:fileadd('[image|<? echo $truename ?>|RIGHT]')"><img
src="images/icon.right.gif" width="24" height="24" alt="Insert Image Aligned
Right" border="0"></a>
<?
if (($newsfeed_userinfo[userlevel] > 69) OR ($newsfeed_userinfo[userid] ==
$owner)) {
print " <a href=\"javascript:usure('Delete this image?',
'upload.php?actioning=remove&id=$theid')\"><img
src=\"images/icon.delete.gif\" width=\"24\" height=\"24\" alt=\"Delete this
image from file\" border=\"0\"></a>";
}
print "</td></tr>";
$i++;
endwhile;
}
print "</table>";
# Do Files Now
$query2 = "SELECT * FROM $newsfeed_variable[filetable] WHERE (filetype =
'file' ) ORDER BY $newsfeed_variable[filetable].filename ASC";
$result = mysql($newsfeed_variable[dbname], $query2 );
$num = mysql_numrows($result);
if ($num != 0) { ?>
<br>
<table width="98%" border="0" cellspacing="2" cellpadding="2"
align="center">
<tr class="titlebar">
 <td colspan="3" class="titlebar">Available Files</td>
</tr>
<tr class="tableheader"><td>File Names</td><td>File
Size</td><td>Add?</td></tr>
<?
$i = 0;
while ($i < $num) :
$theid = mysql_result($result,$i,"fileid");
$truename = mysql_result($result,$i,"fileTrueName");
$filename = mysql_result($result,$i,"filename");
$filesize = mysql_result($result,$i,"filesize");
$owner = mysql_result($result,$i,"fileowner");
if ($class == 'odd') {$class = 'even';}
else {$class = 'odd';}
?>
<tr class="<? echo $class ?>">
<td><? echo $filename ?></td>
<td><? echo $filesize ?></td>
<td>
<a href="javascript:fileadd('[file|<? echo $truename?>|]')">Add</a>
<?
if (($newsfeed_userinfo[userlevel] > 69) OR ($newsfeed_userinfo[userid] ==
$owner)) {
print " | <a href=\"javascript:usure('Delete this file?',
'upload.php?actioning=remove&id=$theid')\">Remove</a>";
}
print "</td></tr>";
$i++;
endwhile;
}
print "</table>";
}
?>

 il formato supportato da aruba?
Non ho letto il codice, non so cosa si può fare con aruba, ma il manuale
dice:
http://it2.php.net/manual/it/ref.image.php
e poi va nel dettaglio:
http://it2.php.net/manual/it/function.imagecopyresampled.php
Ludovico