0
我无法确定使用Zend Framework上传的图片的文件类型。 每次我尝试使用$ _FILES ['File'] ['type']来确定文件类型时,我总是得到applicationoctet-stream。只有在检查表单是否发布之前确定类型时,我才能得到正确的扩展名。有谁知道为什么?有没有更好的方法来处理这个问题?使用Zend上传图片形式确定图片扩展
这个工程:
$form = new Form_Reg;
$this->view->Reg = $form;
if(isset($_FILES['File']['type'])){
$filetype = $file = $_FILES['File']['type'];
}
if ($this->getRequest()->isPost()){
$formData = $this->_request->getPost();
if($form->isValid($formData)){
echo $filetype;
exit;
}
}
这不起作用:
$form = new Form_Reg;
$this->view->Reg = $form;
if ($this->getRequest()->isPost()){
$formData = $this->_request->getPost();
if($form->isValid($formData)){
$filetype = $file = $_FILES['File']['type'];
echo $filetype;
exit;
}
}
总是在我的AK的问题,我找到了答案:): 这是获得扩展的好得多的办法: \t $ arr_pathinfo = PATHINFO($形式 - >文件 - >的getFileName()); \t $ extension = strtolower($ arr_pathinfo ['extension']); – Tosh
如果你的答案是正确的,请发表评论作为答案,然后接受它,这样每个人都可以轻松地看到它。 –