0

i want to generate the thumbnail image from the uploaded video but the problem is that the thumbnail image is not generating. The uploaded video goes to the uploads folder but at this place the image is not generating..Please look at the code, and tell me where i am wrong.

public function add_video() {                   // move_upload_file code

    if(!empty($_FILES['video']['name'])){

        $tmp_name_array = $_FILES['video']['tmp_name'];
        $n_array = $_FILES['video']['name'];
        $exp = explode('.', $n_array);
        $newnme = date('his').rand().'.'.end($exp);
        $raw_name = explode('.', $newnme);

        $full_path = base_url('uploads').'/'.$newnme;
        $new_path = base_url('uploads').'/';
        if(move_uploaded_file($tmp_name_array, "uploads/".$newnme))
        {                
            $full_path = base_url('uploads').'/'.$newnme;
            $new_path = base_url('uploads').'/';

            print_r(exec("ffmpeg -i ".$full_path." ".$new_path.$raw_name[0].".jpg"));

            echo "uploaded Successfully";
        }
    }else{

        echo "not selected any file";
    }
}
M. Eriksson
  • 13,450
  • 4
  • 29
  • 40
  • 1
    echo out `"ffmpeg -i ".$full_path." ".$new_path.$raw_name[0].".jpg"` and see if the path name/file exists. – Blue Sep 27 '18 at 06:09
  • https://stackoverflow.com/questions/2043007/generate-preview-image-from-video-file – Aditya Chawla Sep 27 '18 at 06:10
  • if you see the $full_path and $new_path variable it shows the full path to the folder just see the below code when i vardump both variable (full_path and $new_path) ip_address/project/uploads/070815856902320.mp4 ip_address/project/uploads/ – Amit Gupta Sep 27 '18 at 06:14
  • Thanks Frankerz it works for me...i just remove the base_url from these two variable ($new_path and $full_path). Now the thumbnail image is generating properly – Amit Gupta Sep 27 '18 at 06:21
  • google absolute vs relative paths for future reference. file upload, dealing with anything file related, should never involve a url ;) – Alex Sep 27 '18 at 07:37

0 Answers0