6
2 개 이상의 이미지를 선택하더라도 하나만 업로드됩니다. 내 컨트롤러에서 다음Zend 프레임 워크로 여러 파일을 업로드하는 방법은 무엇입니까?
<form action="/images/thumbs" method="post" enctype="multipart/form-data">
<input name="file[]" id="file" type="file" multiple="" />
<input type="submit" name="upload_images" value="Upload Images">
</form>
:
public function thumbsAction()
{
$request = $this->getRequest();
if ($request->isPost()) {
if (isset($_POST['upload_images'])) {
$names = $_FILES['file']['name'];
// the names will be an array of names
foreach($names as $name){
$path = APPLICATION_PATH.'/../public/img/'.$name;
echo $path; // will return all the paths of all the images that i selected
$uploaded = Application_Model_Functions::upload($path);
echo $uploaded; // will return true as many times as i select pictures, though only one file gets uploaded
}
}
}
}
과 upload
방법 : 난 단지 하나 개의 파일을받을 이유
public static function upload($path)
{
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->addFilter('Rename', array(
'target' => $path,
'overwrite' => true
));
try {
$upload->receive();
return true;
} catch (Zend_File_Transfer_Exception $e) {
echo $e->message();
}
}
어떤 아이디어가 업로드
나는 간단한 양식을 ?
여기 코드에 문제가 있다고 생각합니다. '$ apt'가 정의되지 않았습니다. '$ upload'를 원하셨습니까? –
변경 .. 죄송합니다 .. – Dinesh
감사합니다. Zf2의 트릭입니다. –