0
votes

i have been using RackSpace CloudFiles to store certain images. I have the upload code working perfectly but when I try and read the image from CloudFiles it wont display it. The images wont render into the browser. The file is definitely being read as I can see the actual data from it but if I try and put in a header to render it out as an image it doesnt work. Is my code wrong?

$auth = new CF_Authentication("x", "x");
$auth->authenticate();
$conn = new CF_Connection($auth);
$cont = $conn->get_container("attachments");
$attachment = $cont->get_object("test.gif");
header("Content-Type: " . $attachment->content_type);
$output = fopen("php://output", "w");
$attachment->stream($output);
fclose($output);
1
What happens if you run the script and instead of dumping the contents just print $attachment->content_type ? - Marco Ceppi
I get the content type back. image/gif - christophmccann
Its weird because it seems to get all the data from the file - i can print the string out. But if i tell the browser to render it using headers then it just gives me the little question mark image icon. - christophmccann

1 Answers

0
votes

sorted - very silly mistake! had a little space before the opening php bracket meaning there was output before the header! Silly silly silly