Re: offering downloads of blobs (mysql) with php

  • From: "Jacob Kruger" <jacobk@xxxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sat, 30 Apr 2011 11:19:14 +0200

That would generally be related to redirecting content from another source, so it wants to change the file/content type that the browser is expecting as such.


For example, the one thing I have is checking if someone is logged in to a site, before sending them a word document directly from a PHP script - idea is partly so they wouldn't be able to know/see the actual file path/URL, but the PHP script tells the browser it's receiving a word document, and then passes it through to the browser:

$PhysicalFileName = "cnsttn/constitution.doc";
header('HTTP/1.1 200 OK', True, 200);
header('Content-Description: File Transfer');
header('Content-Type: application/msword');
header('Content-Disposition: attachment; filename="constitution.doc"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($PhysicalFileName));

// readfile() will simply pass the file from the drive straight to the client.
readfile($PhysicalFileName);
exit;
//that last statement closes the browser/server transaction/communication as such


Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'

----- Original Message ----- From: "Alex Hall" <mehgcap@xxxxxxxxx>
To: "programmingblind" <programmingblind@xxxxxxxxxxxxx>
Sent: Saturday, April 30, 2011 2:34 AM
Subject: offering downloads of blobs (mysql) with php


Hi all,
I have a database project due next Wednesday. It is done, but I am
adding things since I have the time (and I really don't want to do my
calc homework right now). One of my databases is for podcasts, the
other for articles. The articles one is fine; I can serve that content
since it is stored in a longtext field, so I need only echo it to the
page. The podcast table is different, though. I looked up this stuff
already, but was taken to a script that was using a header() function
(php) and giving it mime information about the file, then it echoed
the blob, and that was it. I am wondering:
1. What is all this mime stuff about?
2. My only experience with files and webpages is putting a link to a
file, even a binary one, and letting the browser take care of it. Why,
then, did the script I found echo the blob and leave it at that? It
was not generating an html page with a link; the link was to
download.php, and download.php was the one doing all this with the
mime information and the echoing of the blob.
3. Does anyone know of a good resource to find out more about serving
blobs so users can download them? Most of what I find is about
displaying images stored as blobs, but I want to offer a download link
for a given podcast's media file.
Thanks in advance.

--
Have a great day,
Alex (msg sent from GMail website)
mehgcap@xxxxxxxxx; http://www.facebook.com/mehgcap
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: