Wednesday, March 8, 2017

Undefined offset when explode image

i am trying to make a image upload on Laravel Rest Api. When i try to upload and save image in localhost it works fine, but when i try to do the same thing with the same code in my server i get a "Undefined offset: 2", here is my code

 list($width, $height) = getimagesize($file);
            $extension = $file->getClientOriginalExtension();
            $final_filename = $file->getFilename() . '.' . $extension;
            $name = explode('.',$final_filename)[0];
            $extension = explode('.',$final_filename)[2];
            $final= $name.'.'.$extension;

Thanks in adavance.



via User45648

Advertisement