codice:
<?php
ob_start();
$site = "http://www.sialgroup.com/"; //site name with the directory that the uploading file is on ex. http://your_site/phpimages/
$directory = "promozioni/"; //directory name, where all the images upload
$size = "1000000"; //maximum size of image in bytes
$image_width = "100";
//show the upload file form
//echo "
";
echo "<center>";
//print the number of images in the directory
/*
you can delete this
if you want
*/
//echo count(glob($directory . "*")) . " immagini caricate dagli utenti.";
//echo "
";
echo "<form enctype=multipart/form-data method=post action=?action=upload><input name=userfile type=file><input type=submit value=Upload></form>";
//echo "
";
if($_GET['action'] == 'upload')
{
$uploaddir = $directory;
$trim = str_replace(" ", "",basename($_FILES['userfile']['name']));
$name = strtolower($trim);
srand((double)microtime()*1000000);
if(substr($name, -5, 5) == '.jpeg' || substr($name, -5, 5) == '.JPEG' || substr($name, -5, 5) == '.tiff' || substr($name, -5, 5) == '.TIFF')
{
$number2 = date("y"). date("m") . date("d") . "_" . rand(0,100000000) . substr($name, -5, 5);
}
else
{
$number2 = date("y"). date("m") . date("d") . "_" . rand(0,100000000) . substr($name, -4, 4);
}
$uploadfile = $uploaddir . $number2;
// check width image
if ($_FILES['userfile']['image_width'] == $image_width || $_FILES['userfile']['image_width'] > $image_width)
{
echo "La foto caricata risulta più larga di " . $image_width . "pixel";
}
//check the image size
if($_FILES['userfile']['size'] == $size || $_FILES['userfile']['size'] > $size)
{
$size2 = $size/1000;
echo "Image size should be less than " . $size2 . "kb";
exit;
}
else
{
if(substr($name, -5, 5) == '.jpeg' || substr($name, -4, 4) == '.gif' || substr($name, -4, 4) == '.jpg' || substr($name, -4, 4) == '.png' || substr($name, -4, 4) == '.bmp' || substr($name, -5, 5) == '.JPEG' || substr($name, -4, 4) == '.GIF' || substr($name, -4, 4) == '.JPG' || substr($name, -4, 4) == '.PNG' || substr($name, -4, 4) == '.BMP' || substr($name, -4, 4) == '.tif' || substr($name, -4, 4) == '.TIF' || substr($name, -5, 5) == '.tiff' || substr($name, -5, 5) == '.TIFF' || substr($name, -4, 4) == '.swf' || substr($name, -4, 4) == '.SWF')
{
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
{
echo "Il file è stato caricato con successo
";
//echo "[img] . $directory . $number2 . [/img]
";
// echo "
To send this image to friends and family, copy and paste this code:
<font size=2 color=gray><textarea rows=3 cols=60>" . $site . $directory . $number2 . "</textarea></font>";
echo "Copia e incolla nel campo foto la stringa sottostante:
<font size=2 color=gray><textarea rows=3 cols=60>" . $directory . $number2 . "</textarea></font>";
echo "</center>";
}
else
{
echo "Could not upload image";
}
}
else
{
echo "Not a valid image file";
}
}
}
?>
Lo script fa il casricamento delle foto ma nn il controllo delle stesse.