Welcome Guest, Not a member yet? Register   Sign In
File Validation with redirect
#1

Hi
I have a problem with my file (image) upload.
The upload itself works fine. However, an error occurs in the validation in connection with the resulting redirect, which I cannot explain to myself.
I use this redirect with all form controllers and so far it has output exactly what it should output. As an example I have attached both examples once.
I have also attached the associated private function for validation.
When I use form_open, everything is displayed as it should be displayed.
When I change to form_open_multipart the error occurs

Sorry for my bad english

When I try this the statusError is shown
PHP Code:
if(!$this->validate($this->validation_edit_profile_image())):
    return redirect()->back()
                     ->with('statusError'lang('system/auth/pages/edit_profile_image.messages.error.edit_profile_image'));
else:
    // image upload itself working fine
endif; 

When I add ->with('validation', $this->validator) the statusError and the validation is not shown

PHP Code:
if(!$this->validate($this->validation_edit_profile_image())):
    return redirect()->back()
                     ->with('statusError'lang('system/auth/pages/edit_profile_image.messages.error.edit_profile_image'))
                     ->with('validation'$this->validator);
else:
    // image upload itself working fine
endif; 
In all other controllers where a form is submitted this is working fine, for example
PHP Code:
if(!$this->validate($this->validation_edit_profile())):
    return redirect()->back()
                     ->with('statusError'lang('system/auth/pages/edit_profile.messages.error.edit_profile'))
                     ->with('validation'$this->validator)
                     ->withInput();
else:
    // profile updater
endif; 

Private Validation Function for the Image Upload
PHP Code:
private function validation_edit_profile_image()
    {
        $rules = [
 
'avatar' => [
 
'rules'  => 'uploaded[avatar],is_image[avatar]|ext_in[avatar,png,jpeg,jpg,gif]|mime_in[avatar,image/png,image/jpg,image/jpeg,image/gif]|max_size[avatar,2048]|max_dims[avatar,1024,1024]',
 
'errors' => [
 
'ext_in' => lang('system/auth/validation/clubs.edit_profile_image.profile_image.ext_in'),
 
'is_image' => lang('system/auth/validation/clubs.edit_profile_image.profile_image.is_image'),
 
'max_dims' => lang('system/auth/validation/clubs.edit_profile_image.profile_image.max_dims'),
 
'max_size' => lang('system/auth/validation/clubs.edit_profile_image.profile_image.max_size'),
 
'mime_in' => lang('system/auth/validation/clubs.edit_profile_image.profile_image.mime_in'),
 
'uploaded' => lang('system/auth/validation/clubs.edit_profile_image.profile_image.uploaded')
 ]
            ]
 ];
 return 
$rules;
    
PHP Code:
private function validation_edit_profile()
    {
        $countries_list $this->countriesModel->getCountriesValidationList();
        $languages_list $this->languagesModel->getLanguagesValidationList();
        $nationalities_list $this->countriesModel->getCountriesValidationList();
        $rules = [
 
'country' => [
 
'rules'  => 'required|in_list['.$countries_list.']',
 
'errors' => [
 
'in_list' => lang('system/auth/validation/edit_profile.country.in_list'),
 
'required' => lang('system/auth/validation/edit_profile.country.required')
 ]
            ],
 
'firstname' => [
 
'rules'  => 'required|min_length[3]|max_length[255]',
 
'errors' => [
 
'max_length' => lang('system/auth/validation/edit_profile.firstname.max_length'),
 
'min_length' => lang('system/auth/validation/edit_profile.firstname.min_length'),
 
'required' => lang('system/auth/validation/edit_profile.firstname.required')
 ]
            ],
            'language' => [
                'rules'  => 'required|in_list['.$languages_list.']',
                'errors' => [
                    'in_list' => lang('system/auth/validation/edit_profile.language.in_list'),
                    'required' => lang('system/auth/validation/edit_profile.language.required')
                ]
            ],
            'lastname' => [
 
'rules'  => 'permit_empty|min_length[3]|max_length[255]',
 
'errors' => [
 
'max_length' => lang('system/auth/validation/edit_profile.lastname.max_length'),
 
'min_length' => lang('system/auth/validation/edit_profile.lastname.min_length')
 ]
 ],
            'location' => [
 
'rules'  => 'permit_empty|min_length[3]|max_length[255]',
 
'errors' => [
 
'max_length' => lang('system/auth/validation/edit_profile.location.max_length'),
 
'min_length' => lang('system/auth/validation/edit_profile.location.min_length')
 ]
            ],
            'nationality' => [
                'rules'  => 'required|in_list['.$nationalities_list.']',
                'errors' => [
                    'in_list' => lang('system/auth/validation/edit_profile.nationality.in_list'),
                    'required' => lang('system/auth/validation/edit_profile.nationality.required')
                ]
            ]
 ];
 return 
$rules;
    
Reply


Messages In This Thread
File Validation with redirect - by pyst4r1983 - 11-02-2021, 07:54 AM
RE: File Validation with redirect - by manager - 11-03-2021, 12:37 AM
RE: File Validation with redirect - by pyst4r1983 - 11-09-2021, 02:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB