limitare l’upload di files a sole immagini in php
Posted on 11. Sep, 2007 by Administrator in php, tutorials
<?php
$allowedTypes = array ( "JPEG", "JPG", "GIF", "PNG");
while (list($key, $value) = each ($allowedTypes))
{
if (strtoupper(substr($_FILES['Filedata']['name'],-strlen($value))) == $value)
{
$allow = true;
}
}
if(isset($_FILES['Filedata']))
{
$tmpFile = $_FILES['Filedata']['tmp_name'];
$uploadFolder = $_REQUEST["folder"];
$uploadedFile = $_REQUEST["filename"];
if ( $allow )
{
if ( !file_exists ( "../upload/" . $uploadFolder ) )
{
mkdir ( "../upload/" . $uploadFolder );
chmod ( "../upload/" . $uploadFolder, 0755 );
}
move_uploaded_file( $tmpFile, "../upload/" . $uploadFolder . "/" . $uploadedFile);
chmod( "../upload/".$uploadedFile, 0755 );
}
}
?>





Leave a reply