目前我正在保存用户上传的图像文件,如下所示:
public_html/img/user/$category/$username/$imagename
但是,这是不好的做法吗?为什么存储在文档根目录中是不好的,在哪里存储文件更好?
我过滤扩展如下:
// Check to see if the type of file uploaded is a valid image type
function is_valid_type($file)
{
// This is an array that holds all the valid image MIME types
$valid_types = array("image/jpg", "image/JPG", "image/jpeg", "image/bmp", "image/gif", "image/png");
if (in_array($file['type'], $valid_types))
return 1;
return 0;
}