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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:36:36+00:00 2026-06-02T03:36:36+00:00

I am developing an API system for my uploading service (in PHP). At the

  • 0

I am developing an API system for my uploading service (in PHP). At the current moment I support the option to send image data as binary data from file_get_contents, fread, etc, or by encoding it with 64 based system. I am attempting to determine the extension type of the image being uploaded to my service from this binary/base64 data. If it is base64 then I decode it and then process it.

I have the following at the moment:

// We need to figure it out ourselves
if ($type === "")
{
    // Let's see if it is a base64 file
    $base64 = $this->checkBase64Encoded($file_data);

    // We got a 64 based file or binary
    $type = $base64 === TRUE ? "base64" : "binary";
}

if ($type == "binary")
{
    $im = imagecreatefromstring($file_data);

}

I want to see if it is possible to determine the image extension type for saving the file. What do you guys suggest? I read something about using getimagesize()? Although I am not sure about this. Is there no way to get around temporarily saving the file, processing it, and then renaming it?

I also planned to use this to test that the image was a valid image before i checked for extension but I wasn’t exactly sure how to use the getimagesize() function:

try
        {
            // Get the width and height from the uploaded image
            list($width, $height) = getimagesize($file['tmp_name']); // I'm not sure what to put here instead of $file['tmp_name']
        }
        catch (ErrorException $e)
        {
            // Ignore read errors
        }

        if (empty($width) OR empty($height))
        {
            // Cannot get image size, cannot validate
            return FALSE;
        }

Please feel free to ask for any clarifications if I was unclear. Thanks so much 🙂

  • 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-06-02T03:36:38+00:00Added an answer on June 2, 2026 at 3:36 am

    You’re looking for the fileinfo functions, particularly finfo_buffer().

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

Sidebar

Related Questions

I'm developing a REST API at the moment, and one of the core features
I'm developing a REST api which needs to support optional filtering of properties based
I'm developing API for booking(hotels, cars, apartments, etc.) system. Response will be in XML
I'm Developing a CBIR (Content based Image Retrieval System) as part of my BE
I'm developing a platform API with Java and I must choose an exchange data
We are developing an application which accesses an API exposed over some embedded system.
I'm developing a Mapping Service with Bing Maps AJAX API and SQL Server 2008.
I've been developing a small in house application in C++ to access data from
i am currently developing a API for a service and was wondering if this
I'm developing a system to integrate with an SMS API, and I was wondering

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.