|
-
Feb 13th, 2009, 05:07 AM
#1
Thread Starter
New Member
response.BinaryWrite equivalent in php
Hi, I desperately need help from a php guru.
I am currently converting an asp.net site to php. The existing asp.net site retrieves images from a sqlserver database in the form of byte arrays. A byte array can then be instantly rendered to a page by using the following two lines (where bytArray is my byte array object):-
Response.ContentType = "Image/png"
Response.BinaryWrite(bytArray)
job done.
Simple huh! But can I find a way to do this using php? can I heck!
I have searched and searched for an answer but cannot find anything. I am learning php at the mo, have I missed something obvious? surely there must be a simple way to render a byte array to a php page?
-
Feb 13th, 2009, 07:13 AM
#2
Re: response.BinaryWrite equivalent in php
I've never dealt with ASP.NET or bytes/bits, so I absolutely cannot help you. I do know that PHP does not have a "byte" type of variable, which is what you'd be looking for, I'm pretty sure. I found this resource that may have some information to help you, but I couldn't find anything else.
-
Feb 13th, 2009, 09:01 AM
#3
Hyperactive Member
Re: response.BinaryWrite equivalent in php
How is the data actually stored in the database? It may not actually be stored as a byte but rather converted to a byte array somewhere in code.
If I helped you please rate me.
-
Feb 13th, 2009, 09:23 AM
#4
Re: response.BinaryWrite equivalent in php
Use fwrite or file_put_contents. If the file is being saved in Windows then you can use only fwrite and you need to ensure you open the file with the binary option 'wb'.
PHP Code:
$fhwnd = fopen($fileName, 'wb');
fwrite ($fhwnd, $string); // note this should be a string, not a byte array
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|