PHP adds an extra byte at the beginning of a file.

Discussion in 'PHP' started by educobian, May 16, 2006.

  1. #1
    Hello,

    yesterday I tried to send an excel file using php.
    The file was corrupted and after a lot of effort (and luck) I realised that php(or something in the process) was adding an extr byte at the beginning of the file.

    This is the php code I used:
    <?
    define('FILEDIR', '/home/content/h/l/l/hlluch/html/');
    $path = FILEDIR . $file;
    //send file contents
    $fp=fopen($path, "r");
    fpassthru($fp);
    ?>

    Does anyone know why this is happening?:mad:

    Thanks.
     
    educobian, May 16, 2006 IP
  2. educobian

    educobian Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hello,

    I have solved my problem.

    <? had to be the first thing on the php file.

    I am not a php expert and I didn't recall it.

    But I am surprised that no one thought of that.
     
    educobian, May 19, 2006 IP