升级Composer后,Yii2 nemmo / yii2-attachments文件上传不起作用

时间:2019-01-07 16:19:06

标签: yii2 composer-php php-7 yii2-advanced-app jquery-file-upload

我一直在从事yii2项目,其中包括了基于nemmo/yii2-attachmentshttps://github.com/Nemmo/yii2-attachments)的kartik-v/yii2-widget-fileinputhttps://github.com/kartik-v/yii2-widget-fileinput)。我正在用它来将附件上传到模型。

大约一年前,当我安装扩展程序时,我严格按照文档页面中提供的说明进行操作,之后一切正常。

不幸的是,我最近执行了composer update,此后,上传不再起作用。 我正在使用Apache 2.4.6,PHP 7.0.33,Yii 2.0.16-dev的CentOS 7上运行我的项目。

我的composer.json是:

{
    "name" : "yiisoft/yii2-app-advanced",
    "description" : "Yii 2 Advanced Project Template",
    "keywords" : [
        "yii2",
        "framework",
        "advanced",
        "project template"
    ],
    "homepage" : "http://www.yiiframework.com/",
    "type" : "project",
    "license" : "BSD-3-Clause",
    "support" : {
        "issues" : "https://github.com/yiisoft/yii2/issues?state=open",
        "forum" : "http://www.yiiframework.com/forum/",
        "wiki" : "http://www.yiiframework.com/wiki/",
        "irc" : "irc://irc.freenode.net/yii",
        "source" : "https://github.com/yiisoft/yii2"
    },
    "minimum-stability" : "dev",
    "require" : {
        "php" : ">=5.4.0",
        "yiisoft/yii2" : "~2.0.6",
        "yiisoft/yii2-bootstrap" : "~2.0.0",
        "yiisoft/yii2-swiftmailer" : "~2.0.0",
        "yiisoft/yii2-jui" : "~2.0.0",
        "nemmo/yii2-attachments" : "~1.0.0",
        "phpoffice/phpspreadsheet" : "dev-master"
    },
    "require-dev" : {
        "yiisoft/yii2-debug" : "~2.0.0",
        "yiisoft/yii2-gii" : "~2.0.0",
        "yiisoft/yii2-faker" : "~2.0.0",
        "codeception/base" : "^2.2.3",
        "codeception/verify" : "~0.3.1"
    },
    "config" : {
        "process-timeout" : 1800,
        "fxp-asset" : {
            "installer-paths" : {
                "npm-asset-library" : "vendor/npm",
                "bower-asset-library" : "vendor/bower"
            }
        }
    }
}

包含活动表单的视图文件如下:

...
    <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>

        <?= $form->field($model, 'id')->hiddenInput()->label(false) ?>

        <?= \nemmo\attachments\components\AttachmentsInput::widget([
            'model' => $model,
            'options' => [
                'multiple' => false,
            ],
            'pluginOptions' => [
                'maxFileCount' => 10,
                'showRemove' => false,
                'showUpload' => false,
                'showDrag' => false,
                'showDownload' => true,
                'overwriteInitial' => true,
                'dropZoneEnabled' => false,
                'resizeImage' => true,
                'maxImageWidth' => 200,
                'maxImageHeight' => 200,
                'resizePreference' => 'width',
                'hiddenThumbnailContent' => true,
                'showPreview' => false,
            ]
        ]) ?>

        <div class="form-group">
            <?= Html::submitButton('Add', ['class' => 'btn btn-success']) ?>
        </div>

    <?php ActiveForm::end(); ?>
...

当我尝试上传文件时,文件输入元素的边框变为红色,并且动作在该点冻结。见下图: enter image description here

我注意到app.log中存在以下错误:

...
2019-01-07 15:17:18 [::1][1][pvunpo8kovqn4spntfvj11vju1][error][yii\web\HttpException:404] yii\base\InvalidRouteException: Unable to resolve the request "attachments%2Ffile%2Fupload". in /var/www/html/my-yii2-project/vendor/yiisoft/yii2/base/Module.php:537
Stack trace:
#0 /var/www/html/my-yii2-project/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction('attachments%2Ff...', Array)
#1 /var/www/html/my-yii2-project/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#2 /var/www/html/my-yii2-project/frontend/web/index.php(17): yii\base\Application->run()
#3 {main}

Next yii\web\NotFoundHttpException: Page not found. in /var/www/html/my-yii2-project/vendor/yiisoft/yii2/web/Application.php:115
Stack trace:
#0 /var/www/html/my-yii2-project/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 /var/www/html/my-yii2-project/frontend/web/index.php(17): yii\base\Application->run()
#2 {main}
2019-01-07 15:17:17 [::1][1][pvunpo8kovqn4spntfvj11vju1][info][application] $_GET = [
    'r' => 'attachments%2Ffile%2Fupload'
]

$_POST = []

$_FILES = [
    'UploadForm' => [
        'name' => [
            'file' => [
                0 => 'some-file.pdf'
            ]
        ]
        'type' => [
            'file' => [
                0 => 'application/pdf'
            ]
        ]
        'tmp_name' => [
            'file' => [
                0 => '/tmp/php1wWDEH'
            ]
        ]
        'error' => [
            'file' => [
                0 => 0
            ]
        ]
        'size' => [
            'file' => [
                0 => 45806
            ]
        ]
    ]
]

...

Google chrome开发人员工具显示以下错误(参见图片) enter image description here

顺便说一句,Chrome显示它正在加载jQuery 3.2.1和Bootstrap 3.4.0。

当我运行作曲家更新时,在作曲家日志中看到另一个错误:

The "https://bower.herokuapp.com/packages/jquery-colorbox" file could not be downloaded (HTTP/1.1 502 Bad Gateway)
https://bower.herokuapp.com/packages could not be fully loaded, package information was loaded from the local cache and may be out of date

我不确定这是否与上传问题有关,但我还是想提及它。

您是否知道如何解决此问题并重新进行上传?或者至少在上传正常工作后如何将软件包恢复到以前的状态?

0 个答案:

没有答案