CTOlet / yii2-attachments

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

PHP Notice 'yii\base\ErrorException' with message 'Undefined index: file' #11

Closed larry-tx closed 9 years ago

larry-tx commented 9 years ago

Well, no sooner do I resolve one thing, then another crops up. I can upload image and text (pdf, txt) files just fine, but when I attempt to upload a video file (with appropriate mimeTypes in the rules), then I run into this error:

Internal Server Error

PHP Notice 'yii\base\ErrorException' with message 'Undefined index: file' 
in L:\xampp\htdocs\public_html\vendor\nemmo\yii2-attachments\controllers\FileController.php:41
Stack trace:
#0 L:\xampp\htdocs\public_html\vendor\nemmo\yii2-attachments\controllers\FileController.php(41): yii\base\ErrorHandler->handleError(8, 'Undefined index...', 'L:\\xampp\\htdocs...', 41, Array)
#1 [internal function]: nemmo\attachments\controllers\FileController->actionUpload()
#2 L:\xampp\htdocs\public_html\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array)
#3 L:\xampp\htdocs\public_html\vendor\yiisoft\yii2\base\Controller.php(151): yii\base\InlineAction->runWithParams(Array)
#4 L:\xampp\htdocs\public_html\vendor\yiisoft\yii2\base\Module.php(455): yii\base\Controller->runAction('upload', Array)
#5 L:\xampp\htdocs\public_html\vendor\yiisoft\yii2\web\Application.php(83): yii\base\Module->runAction('attachments/fil...', Array)
#6 L:\xampp\htdocs\public_html\vendor\yiisoft\yii2\base\Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#7 L:\xampp\htdocs\public_html\backend\web\index.php(18): yii\base\Application->run()
#8 {main}

Just to be sure, this is what I have in my config/main.php modules section:

'attachments' => [
                'class'     => nemmo\attachments\Module::className(),
                'tempPath'  => '@app/uploads/temp',
                'storePath' => '@app/uploads/store',
                'rules'     => [ // Rules according to the FileValidator
                                 'maxFiles'  => 15,
                                 'mimeTypes' =>
                                     'image/gif, image/jpeg, image/png, image/tiff/ image/jpg, text/css,
                                        text/csv, text/html, application/javascript, text/plain, text/rtf, text/xml,
                                        application/vnd.ms-excel, application/json, application/pdf, application/msword,
                                        application/vnd.openxmlformats-officedocument.wordprocessingml.document,
                                        application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, video/mp4,
                                        audio/mpeg3, audio/x-mpeg-3, video/mpeg, video/x-mpeg',
                                 'maxSize'   => 1024 * 1024 * 1024 * 1024
                ]
            ],

Would you be so kind as to point me in the right direction on this? I couldn't find anything particularly helpful in runtime/app.log. I tried deleting and adding the file to upload multiple times, and this is all the Apache log reported:

127.0.0.1 - - [11/Apr/2015:10:58:44 -0500] "GET /attachments/file/download?id=29 HTTP/1.1" 200 31544 "http://larrylutz.lcl/how-to/update?id=21" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"
127.0.0.1 - - [11/Apr/2015:10:58:44 -0500] "GET /assets/c62c9d80/config.js?t=F0RD HTTP/1.1" 304 - "http://larrylutz.lcl/how-to/update?id=21" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"
127.0.0.1 - - [11/Apr/2015:10:58:44 -0500] "GET /assets/c62c9d80/skins/moono/editor_gecko.css?t=F0RD HTTP/1.1" 304 - "http://larrylutz.lcl/how-to/update?id=21" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"
127.0.0.1 - - [11/Apr/2015:10:58:44 -0500] "GET /assets/c62c9d80/lang/en.js?t=F0RD HTTP/1.1" 304 - "http://larrylutz.lcl/how-to/update?id=21" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"
127.0.0.1 - - [11/Apr/2015:10:58:44 -0500] "GET /assets/c62c9d80/styles.js?t=F0RD HTTP/1.1" 304 - "http://larrylutz.lcl/how-to/update?id=21" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"
127.0.0.1 - - [11/Apr/2015:10:58:44 -0500] "GET /assets/c62c9d80/contents.css?t=F0RD HTTP/1.1" 304 - "http://larrylutz.lcl/how-to/update?id=21" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"
127.0.0.1 - - [11/Apr/2015:10:58:51 -0500] "DELETE /attachments/file/delete?id=29 HTTP/1.1" 200 2 "http://larrylutz.lcl/how-to/update?id=21" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"
127.0.0.1 - - [11/Apr/2015:10:59:13 -0500] "POST /attachments/file/upload HTTP/1.1" 500 1274 "http://larrylutz.lcl/how-to/update?id=21" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0"

So, once again, I'm kind of at a loss on this one.

CTOlet commented 9 years ago

I dont know why you have that error. A you sure that you send correct model data except for file?