CTOlet / yii2-attachments

Yii2 extension for uploading and attaching the files to the models
66 stars 57 forks source link

Can't save single upload image #22

Closed ramil8090 closed 9 years ago

ramil8090 commented 9 years ago

In FileController.php -> actionUpload we can't save single uploaded image. Where ELSE block you must store file name in $result array. Code must like this

if (is_array($model->file)) { foreach ($model->file as $file) { $path = $this->getModule()->getUserDirPath() . DIRECTORY_SEPARATOR . $file->name; $file->saveAs($path); $result['uploadedFiles'][] = $file->name; } } else { $path = $this->getModule()->getUserDirPath() . DIRECTORY_SEPARATOR . $model->file->name; $model->file->saveAs($path);
!!!!add this string!!!! --> $result['uploadedFiles'][] = $model->file->name; }

CTOlet commented 9 years ago

Why you cannot save single uploaded image? What is wrong? On my site it works fine!

ramil8090 commented 9 years ago

It don't save single file when he uploaded asynchronously because in returned JSON there is no filename, but only empty array

CTOlet commented 9 years ago

Single file? What configuration options did you use? I have uploaded a single file just now and it works good

ramil8090 commented 9 years ago

I will checkout configuration in monday.

ramil8090 commented 9 years ago

Sorry, but i already delete code that emulate error. Anyway i will try again when i will be in office but later. Now i think we must close this issue