Results 1 to 4 of 4

Thread: response.BinaryWrite equivalent in php

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2009
    Posts
    1

    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?

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    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.

  3. #3
    Hyperactive Member
    Join Date
    Jan 2009
    Posts
    448

    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.

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    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 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width