zxbodya / yii2-gallery-manager

93 stars 61 forks source link

It gives 404 when I upload a photo #45

Open Sabirgojayev opened 7 years ago

Sabirgojayev commented 7 years ago

The following is my code. In model:

     public function behaviors()
    {
        return [
             'galleryBehavior' => [
                 'class' => GalleryBehavior::className(),
                 'type' => 'product',
                 'extension' => 'jpg',
                 'directory' => Yii::getAlias('@webroot') . '/images/product/gallery',
                 'url' => Yii::getAlias('@web') . '/images/product/gallery',
                 'versions' => [
                     'small' => function ($img) {
                         /** @var \Imagine\Image\ImageInterface $img */
                         return $img
                             ->copy()
                             ->thumbnail(new \Imagine\Image\Box(200, 200));
                     },
                     'medium' => function ($img) {
                         /** @var Imagine\Image\ImageInterface $img */
                         $dstSize = $img->getSize();
                         $maxWidth = 800;
                         if ($dstSize->getWidth() > $maxWidth) {
                             $dstSize = $dstSize->widen($maxWidth);
                         }
                         return $img
                             ->copy()
                             ->resize($dstSize);
                     },
                 ]
             ]
        ];
    }

In controller:

            'galleryApi' => [
           'class' => GalleryManagerAction::className(),
           // mappings between type names and model classes (should be the same as in behaviour)
           'types' => [
               'product' => CreateNews::className()
           ]
       ],

When I try to add photo it gives the following error: POST http://azreal.az/admin/product/galleryApi?type=product&behaviorName=galleryBehavior&galleryId=10407&action=ajaxUpload 404 (Not Found)

bogdan-baerov commented 7 years ago

I have exactly the same error untitled There is a 404 error for each file that I tried to upload, no damn chance to work...please help

bogdan-baerov commented 7 years ago

Never mind, now I have 500 error