problem using http_send_file with Qcodo

thread: 3 messages  |  last: a year ago  |  started: sunday, april 18, 2010, 1:55 am pdt


#1  |  brocha
Sunday, April 18, 2010, 1:55 AM PDT

Hello,

I have a script that sends a file:

<?
http_send_content_type(“text/plain”);
http_send_file('/path/to/some/file');
?>

This works fine.

If i add the QCodo include to this

<?
include_once('qcodo/includes/prepend.inc.php');
http_send_content_type(“text/plain”);
http_send_file('/path/to/some/file');
?>

it stops working.
I tried to comment out the sending of extra QCodo information in headers inside QApplicationBase.class.php (the line QApplication::InitializeServerSignature();) but this did not help.

Any ideas appreciated.

Thanks,
Brocha

#2  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Wednesday, April 21, 2010, 5:13 PM PDT

Hmm... never used http_send_file personally.

Just out of curiosity, why did you choose to use it?

I typically do something like:

<?php
    
require('../path/to/prepend.inc.php');

    
header('Content-Type: foo/bar');
    
header('Content-Length: ' filesize('/path/to/file'));
    print 
file_get_contents('/path/to/file');
?>

works like a charm for me...

#3  |  Fernando Lordán (Barcelona, CAT, Spain) Spain
Monday, May 31, 2010, 5:10 PM PDT

One little comment to add to Mike Ho's snippet of code:

When dumping files to the browser use print, never echo. I thought they were the same functionality until I faced IE's security alerts for no evident reason, and solved them simply by “printing” instead of “echoing”.



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.