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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:10:05+00:00 2026-06-03T08:10:05+00:00

In a server sided script I am using the following PHP code to encode

  • 0

In a server sided script I am using the following PHP code to encode an image:

    $handle = fopen($imageSrc,'r');
    $file_content = fread($handle,filesize($imageSrc));
    fclose($handle);
    $encoded = base64_encode($file_content);

    echo $encoded;

When I read the file through a webservice it has the length 9309 bytes which is an invalid length for base64 encoded data. Examining the data, I found out that the value last byte is 10 (LF). Right now I am cropping the last byte away in my webservices before decoding the data. Is there a clean way to avoid the LF character to be sent?

  • 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-03T08:10:07+00:00Added an answer on June 3, 2026 at 8:10 am

    I’m not sure what is causing this, but having debugged similar issues in the past, I would assume that there is something below the echo causing a \n to be output.

    To test this, put a die(); directly after the echo. If my theory is correct, you can either just leave the die();, or (better) move it progressively downwards in the execution flow until you find whatever is causing the \n to be output.

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

Sidebar

Related Questions

Microsoft recommends their Script Encoder to encode asp.net scripts on server side from nosy/prying
To scroll down my chat DIV I am using the following code which is
Im using the following ajax code to submit data from a form to a
I am trying to write a server side script (PHP) for generating an SVG
I have a server-side php-script that fetches results from a MySQL table. I am
So basically I am using jQuery Datatables server-side functionality with PHP to retrieve a
I have found the following script which is apparently written using the javascript framework
I have a php script to retrieve data from a MysQL databse following an
I am trying to achieve the following: I have a server-side script that generates
The server side team are using the following MVC ScriptManager in my current project

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.