目前我已允许上传.jpg文件。上传验证,允许其他扩展?
如何添加jpeg,gif和png?
我当前的代码如下...
$filename = basename($_FILES['photo']['name']);
$ext = substr($filename, strrpos($filename, '.') + 1);
//Check if the file is JPEG image and it's size is less than 5Mb
$allowedExts = array('jpg', 'jpeg', 'gif', 'png');
if ((in_array($ext, $allowedExts)) && ($_FILES["photo"]["type"] == "image/jpeg") && ($_FILES["photo"]["size"] <= 5242880)){
//Determine the path to which we want to save this file
$newname = str_replace(' ', '_', trim(strip_tags($_POST['name']))) . _ . $formKey->generateKey() . '_' . time() . '.jpg';
当然,你可以有至少一个猜测,并有一个很好的机会,它是正确的。走了,我们会告诉你它是否正确。 – alex
@alex:谢谢。已上传编辑 – Dave
更新了进一步尝试的编辑。 – Dave