/    Sign up×
Community /Pin to ProfileBookmark

PHP download file from DB

I searched through the forum and foundno answers, but many similar cases.

this code:

[code=php]<?php include ‘../sessioncheck.php’; ?>
<?php

if(isset($_GET[‘id’]))
{
include ‘../inc/opendb.php’;
include ‘../inc/datesandtimes.php’;

$id = $_GET[‘id’];
$fname = $_GET[‘name’];
$query = “SELECT name, type, size, content FROM documents WHERE id = ‘$id'”;
$result = mysql_query($query) or die(‘Error, query failed’. mysql_error());
list($name, $type, $size, $content) = mysql_fetch_array($result);
header(“Content-Disposition: attachment; filename=$fname “);
header(“Content-length: $size”);
header(“Content-type: $type”);
echo $content;

exit;
} else {
echo ‘<script>window.location.href=”/documents/download.php”</script>’;
}

?>[/code]

is being fed an ID & name value from another page. This, in turn, calls a specific file stored IN THE MYSQL DB for download.

This works perfectly in Fire Fox, bur not in IE (both 6 and 7).
In IE I get Internet explorer cannot download downloaddocument.php (that’s the name of the php file, not the attachment)
Internet explorer was not able to open this internet site ….

I should mention that the site is encrypted (https).

Any ideas why?

Thanks.

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @Meni spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...