Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Convert Binary String to Image and store locally

Posted on 2008-06-26
2
Medium Priority
?
1,314 Views
Last Modified: 2013-12-12
I'm hoping this question is fairly simple but i'm having some trouble with it.
I'm trying to convert a binary string into an image.  I'm using a system where you call a web service to request an image and they send it back in binary format.  I'm to use this to store the file locally.  I"m having trouble storing this locally.

Here is some information about the data being returned:

MIME-Version: 1.0
Transfer-Encoding: chunked
Cache-Control: private
Content-Type: multipart/parallel; boundary="AABBCCDD"; charset=utf-8

And this is an example of the binary data being returned that i want to store as an image:

--AABBCCDD Content-Type: image/jpeg Content-ID: 1234 Object-ID: 0 ýýýýJFIF``ýýC    $.' ",#(7),01444'9=82<.342ýýC  2!! ... --AABBCCDD--

I know this data has boundaries set so i need to grab what's in between and store the image locally.  I'm hoping this can be done in PHP.

If more information is needed please let me know.
Any and all help is much appreciated.
Thanks in advance.

Adam
0
Comment
Question by:ahanley409
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
virmaior earned 2000 total points
ID: 21883346
how are you getting the image?

that looks like curl output.

what are you getting the data from?  (that would determine what you need to do in order to clip the headers).

basically, something like this:
$start_pos = strpos($my_string,'ýýýý');
$my_image = substr($my_string,$start_post,strlen($my_string) - $start_pos);
$my_file = fopen('c:\\temp\\temp.jpg','w');
fwrite($my_file,$my_image);
fclose($my_file);
0
 

Author Closing Comment

by:ahanley409
ID: 31471134
Yes it was curl output :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question