0
header("Content-type: ".$response->strExtension.""); 
header("Content-length: ".$response->intSize.""); 
header("Content-Disposition: attachment; filename=".basename( $response->strFileName ).""); 
exit(base64_decode($response->binFile));

Im generating an image using the above code. But when checking the generated image using notepad++ it has a newline before the data itself so I get error in opening the image. Like below:

enter image description here

How can I make sure that the generate file has no space or new lines.

Tried trimming the echoed base64_decode($response->binFile) but it didnt do the job. No other echo are executed in this scenario.

Community
  • 1
  • 1
guradio
  • 15,524
  • 4
  • 36
  • 57

1 Answers1

0

You can try some of the approaches here for removing whitespaces in your base64: remove whitespaces from base64 encoded string when posting . Hope this helps! :)

  • Please don't post link-only answers. If that link changes, then the answer will be pointless for future visitors. If you find a solution here at StackOverflow, the question should be marked as a duplicate. If you don't have enough rep for that, you should work on that instead. – M. Eriksson Feb 08 '19 at 06:43