This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Asinox
Asinox

Hello guys, i have a problem with OctoberCMS and upload files, exactly with images, OctoberCMS keep asking about the "image extension" but the image extension is right, and i don't know how fix this or there is something wrong with my code.

Dont care if the file has the correct extension...OctoberCMS keep asking..

Any help please?


try {
                    $uploadedFile = Input::file('photos'); // lot of fields there
                    $validationRules = ['max:'.System\Models\File::getMaxFilesize()];
                    $validationRules[] = 'mimes:jpg,jpeg,bmp,png';

                    $validation = Validator::make(
                        ['photos' => $uploadedFile],
                        ['photos' => $validationRules]
                    );

                    if ($validation->fails())
                        //throw new October\Rain\Support\ValidationException($validation);
                         //throw new ValidationException($validation);
                         $this['message'] = $validation->errors()->toArray();
                        return false;

                    if (!$uploadedFile->isValid())
                       // throw new Exception('File is not valid');
                       $this['message'] = $validation->errors()->toArray();
                        return false;

                    foreach ($uploadedFile as $photo) {
                        $file = new System\Models\File;
                        $file->data = $photo;
                        $file->save();

                        $classified->images()->add($file, post('session_key'));
                        die('success');
                    }

                } catch (\Exception $ex) {
                    die($ex->getMessage());
                }

Last updated

Asinox
Asinox

Any update here please?

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.