Witam,
rzućcie okiem na kod i doradźcie coś, żeby mi uploadowało wszystkie wybrane pliki zamiast tylko jednego.
Oto mój kod:
public function reArrayFiles(&$file_post)
{
$arr = array();
$file_count = count($file_post['name']);
$file_keys = array_keys($file_post);
for ($i=0; $i<$file_count; $i++) {
foreach ($file_keys as $key) {
$arr[$i][$key] = $file_post[$key][$i];
}
}
return $arr;
public function addPhotos($files)
{
if($this->checkUploadErrors($files)===true) {
$photos = $this->reArrayFiles($files);
foreach($photos as $key){
$uid=uniqid();
$ext=pathinfo($key['name'],PATHINFO_EXTENSION);
$fileName='img_'.$uid.'.'.$ext;
$imagine=new Imagine\Gd\Imagine();
$mode=Imagine\Image\ImageInterface::THUMBNAIL_OUTBOUND;
$size=new Imagine\Image\Box(200, 200);
$imagine->open($key['tmp_name'])
->thumbnail($size,$mode)
->save(__DIR__.'/../../img/'.$fileName);
//return $fileName;
}
}
}