skip to Main Content

I have telegram bot receiving a photo in webhook. I can download photo but not get file extension. How to get image extension and optionally mime-type from variable containing photo?

2

Answers


  1. You can use the buffer method on an finfo instance to get the mime type of an arbitrary string blob if you don’t want to write it to disk first:

    // Just a small image from http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever
    $blob = base64_decode('R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');
    
    $finfo = new finfo(FILEINFO_MIME);
    echo $finfo->buffer($blob) . "n";
    
    // Result: image/gif; charset=binary
    

    Demo: https://3v4l.org/EJ95S

    Login or Signup to reply.
  2. How to retrieve the values in my excel file with PHPExcel using WHILE or FOR loop
    i have data in my worksheet between cells A8:A23 AND F8:F23. I need to transfer those data to mysql database with a submission button using phpexcel
    i have an input file name=’fichier’.

    Someone can help me please ?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search