PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, January 19, 2022

[FIXED] Laravel 5 File Uploading getClientOriginalExtention does not exist error

 January 19, 2022     laravel, laravel-5, php     No comments   

Issue

when i`m developing file uploading using laravel 5.4 it gives this error.

Method getClientOriginalExtention does not exist.

Here is my UploadController.

    public function insertFile(){
        $filetitle=Input::get('file_title');
        $file=Input::file('filenam');
    $rules = array(
   'file_title' => 'required',
    'filenam' => 'required|max:20000|mimes:doc,docx,pdf,jpg,png,jpeg'
            );

        $validator = validator::make(Input::all(), $rules);

        if($validator -> fails()){
            $messages=$validator -> messages();
            return Redirect::to('upload')->withInput()->withErrors($validator);

        }
        else if($validator -> passes()){
            if(Input::file('filenam')->isValid()){
                $extention=Input::file('filenam')->getClientOriginalExtention();
                $filename=rand(11111,99999).'.'.$extention;

                $destinationPath='up_file';
                $file->move($destinationPath, $filename);

                $notification = array(
                    'message' => 'File Uploaded Successfully',
                    'alert-type' => 'success'
                    );

                return Redirect::to('upload')->with($notification);
            }
            else{
                $notification = array(
                    'message' => 'File is not Valid!',
                    'alert-type' => 'error'
                    );

                return Redirect::to('upload')->with($notification);
            }
        }
    }

can anyone help me to solve this. thank you very much


Solution

You have misspelled getClientOriginalExtension It will be 's' instead of 't' in extension.



Answered By - im_tsm
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing