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 6882619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:16:34+00:00 2026-05-27T05:16:34+00:00

I wanna save mail attachments with size in database. So I open mail in

  • 0

I wanna save mail attachments with size in database.

So I open mail in text mode by php,for attachments I can see something like example:

Content-Type: image/jpeg; name="donoghte D2.jpg"
Content-Disposition: attachment; filename="donoghte D2.jpg"
Content-Transfer-Encoding: base64
X-Attachment-Id: f_gvn2345e0
/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcG
BwcICQsJCAgKCAcHCg0KCgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwM ...

I will show it by this code

<?php
header('Content-Type: image/jpeg');
echo (base64_decode($text));
?>

If I wanna to calculate the size of this file,and store it and its size in database,what is the best way?

  1. Should I save encode64 of this(like what sent in mail) in a database?
  2. If so, what should the datatype of that field be?
  3. To calculate size of it, should I decode it, then get strlen of it? or is there any faster way?

with special thanks for your attention

  • 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-27T05:16:35+00:00Added an answer on May 27, 2026 at 5:16 am

    You’re dealing with a binary object there, so it’s probably best to store it as the same. I’m not sure what database you’re using, but MySQL has the BLOB (Binary Large OBject) for this exact purpose.

    You could also write it to the file system. There’s dozens of good discussions about the merits of both techniques on Stack Overflow, so I won’t go into it here (eg: Storing images in DB? Yea or Nay?)

    I believe that if you have the decoded data in a string, then strlen would give you the file size of it. You could also query the database or filesystem after storage to get it.

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

Sidebar

Related Questions

I wanna do something like the safari app when fill a form, so when
I wanna rewrite links like index.php?page=entry&id=15&action=edit to entry/15/edit . This is how my .htaccess
I wanna creating canvas (scribble pad) where users can write something with a brush
i wanna save state of QCheckBok in QSetting, i can cast its value to
I wanna stop the reading of my text input file when the word synonyms
I wanna list a external webpage's ulr's content. like i wanna list the content
I wanna to achieve an effect like a fired blue ball (ball with energy)
I'm implementing some kind of AdressBook and wanna save all the contacts in some
Hi How can I save 2 last winform state? I use it when user
i wanna Compare a Text with the all records in a table in the

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.