/    Sign up×
Community /Pin to ProfileBookmark

Problem With File Download Please help

HI,

My files become corrupt as soon as I download them with readfile(),
I notice in my text files that there is an added box in the very beginning so I am guessing the server is messing with the file. I have downloaded via ftp to make sure its not the upload part, and it wasnt its during the download.

Here is my code: The name to the table is changed with “Databasehiddenfrom….”

[code=php]
<?php

//Duckboy81 Custom Duckload_Upload Created By YOURS TRUELEY
//THIS IS THE DOWNLOAD SECTION

if (!eregi(“modules.php”, $PHP_SELF)) {
die (“You can’t access this file directly…”);
}

if (isset($pickup)) {
require_once(“mainfile.php”);
$results = $db->sql_query(“SELECT filename, source, ext, filesize, filetype FROM DATABASEHIDDENFROMYOUREYES WHERE pickup=’$pickup'”);
list($filename, $source, $ext, $size, $type) = mysql_fetch_array($results);

header(“Expires: Mon, 26 Jul 1997 05:00:00 GMT”);
header(“Content-Disposition: attachment; filename=$filename”);
header(“Content-length: $size”);
header(“Content-type: $type”);
readfile(“$source”);

}else{
$error_MSG = “<p><p><br><b>THE FILE YOU REQUESTED COULD NOT BE FOUND.</b></br></p></p>”;

$index = 1;
require_once(“mainfile.php”);
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include(“header.php”);
$pagetitle = “- Duckload Download”;

title(“<img src=’modules/$module_name/duckload_download.gif’ width=’248′ height=’123′ alt=’Duckboy81 Easy Download!’>”);
echo “<center><font class=”content”><b>Welcome To The Download Module For Uploaded Files</b></font></center>$error_MSG”;

}

?>[/code]

THANKS FOR ANY ADVICE!!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@stephan_gerlachMar 26.2007 — this sounds to me like there is a whitespace in your php file which is sent to the browser before you even read the file.

try this:

make sure there is no space or anything before the <?php
[code=php]
<?php

//start an output buffer. This means that all information is being captured and stored in a buffer until the script has finished and is then sent to the browser
ob_start();


//Duckboy81 Custom Duckload_Upload Created By YOURS TRUELEY
//THIS IS THE DOWNLOAD SECTION

if (!eregi("modules.php", $PHP_SELF)) {
die ("You can't access this file directly...");
}

if (isset($pickup)) {
require_once("mainfile.php");
$results = $db->sql_query("SELECT filename, source, ext, filesize, filetype FROM DATABASEHIDDENFROMYOUREYES WHERE pickup='$pickup'");
list($filename, $source, $ext, $size, $type) = mysql_fetch_array($results);

// This will delete the entire output buffer. all whitespaces will hopefully be gone.
ob_clean();

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-Disposition: attachment; filename=$filename");
header("Content-length: $size");
header("Content-type: $type");
readfile("$source");

}else{
$error_MSG = "<p><p><br><b>THE FILE YOU REQUESTED COULD NOT BE FOUND.</b></br></p></p>";


$index = 1;
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include("header.php");
$pagetitle = "- Duckload Download";


title("<img src='modules/$module_name/duckload_download.gif' width='248' height='123' alt='Duckboy81 Easy Download!'>");
echo "<center><font class="content"><b>Welcome To The Download Module For Uploaded Files</b></font></center>$error_MSG";

}


?> [/code]
Copy linkTweet thisAlerts:
@duckboy81authorMar 27.2007 — Thankyou Much!!!
×

Success!

Help @duckboy81 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 5.4,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

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