Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6778149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:13:58+00:00 2026-05-26T16:13:58+00:00

You can do this if the file is a file in the filesystem: shell_exec("file

  • 0

You can do this if the file is a file in the filesystem:

shell_exec("file -bi $file")

But how can you do it if the file is a string (not yet saved as a file)?

The string/file is extracted from an email with imap_fetchbody()

edit

$body = imap_fetchbody($this->stream, $this->msgno, $section);

$finfo = new finfo(FILEINFO_MIME);
echo $finfo->buffer($body) . "\n";

$file = Init::$dynamic['data_path'].$this->msgno.'_'.$part->dparameters[0]->value;
imap_savebody($this->stream, $file, $this->msgno, $section);

echo $finfo->file($file) . "\n";

both $finfo->buffer() and $finfo->file() returns text/plain; charset=us-ascii even if its PDF, PNG etc.?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:13:58+00:00Added an answer on May 26, 2026 at 4:13 pm

    finfo_buffer

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The docs for django.core.files.File imply I can do this: print File(open(path)).url but the File
I can read XLS file with this code : string path =@c:\r\1.xlsx; OleDbConnection MyConnection
can I do this in a loop, by producing the file name from the
I want to delete my entire plist file from the filesystem programmatically. How can
I have a file named my file.pdf and I can't delete this file with
Is it ok to share the iOS development.provision file with others ? can this
I want to create this parameter file so that I can send it to
Can anyone help me to add a restriction to this schema file (for OwnerEnglishName)?
I can make batch or vbs file on windows and run. this can automate
I am using an XML file to store the values. This XML file can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.