You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RedactorController.php: public function actionUpload($dir = '') { // $fileInstance = UploadedFile::getInstanceByName('file'); $fileInstance = UploadedFile::getInstancesByName('file'); if ($fileInstance) { if(is_array($fileInstance)) { $returns = []; foreach ($fileInstance as $key => $file) { if($f = Image::upload($file,$dir)) { $d = $this->getResponse($f); $returns["file-{$key}"] = array_combine(array_merge($d, ['filelink'=> 'url','filename' => 'id']), $d); } } return $returns; } $file = Image::upload($fileInstance, $dir); if($file) { return $this->getResponse($file); } } return ['error' => 'Unable to save image file']; }
Changes made to handle multiple file /image upload.
Changes made to keys of return object(s)
The return used to look like this: {"filelink":"/uploads/2018/04/85mm-f1-4-ex-dg-hsm-320-84a-9be06c2a4c.jpg","filename":"85mm-f1-4-ex-dg-hsm-320-84a-9be06c2a4c.jpg"}
Now it looks like: {"file-0":{"url":"/tmp/images/5723e114ae4775a61c10fe168c18600a.jpg","id":"5723e114ae4775a61c10fe168c18600a"}}
The text was updated successfully, but these errors were encountered:
RedactorController.php:
public function actionUpload($dir = '') { // $fileInstance = UploadedFile::getInstanceByName('file'); $fileInstance = UploadedFile::getInstancesByName('file'); if ($fileInstance) { if(is_array($fileInstance)) { $returns = []; foreach ($fileInstance as $key => $file) { if($f = Image::upload($file,$dir)) { $d = $this->getResponse($f); $returns["file-{$key}"] = array_combine(array_merge($d, ['filelink'=> 'url','filename' => 'id']), $d); } } return $returns; } $file = Image::upload($fileInstance, $dir); if($file) { return $this->getResponse($file); } } return ['error' => 'Unable to save image file']; }
Changes made to handle multiple file /image upload.
Changes made to keys of return object(s)
The return used to look like this:
{"filelink":"/uploads/2018/04/85mm-f1-4-ex-dg-hsm-320-84a-9be06c2a4c.jpg","filename":"85mm-f1-4-ex-dg-hsm-320-84a-9be06c2a4c.jpg"}
Now it looks like:
{"file-0":{"url":"/tmp/images/5723e114ae4775a61c10fe168c18600a.jpg","id":"5723e114ae4775a61c10fe168c18600a"}}
The text was updated successfully, but these errors were encountered: