Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: May 2002
Posts: 12
Newbie
Newbie
Offline
Joined: May 2002
Posts: 12
I use the following file get.php - to let users download some video files ONLY through the get.php file. The video files (WMV, MPG, RAM, RM) are stored in an 'outside' webroot directory and are called by get.php.

The problems however -

(a) Every file downloaded is named get.<extension>
(b) The RM or real media files are corrupt after open/ download through this script. It downloads the perfect size for Real Media, but then it fails to open

MPEG files run fine though. Any help greatly appreciated.


The PHP code for get.php--



<?
define('FILEDIR', '/home/myhotboard.com/downloads/');
//storage directory outside the root
$path = FILEDIR . $file;

$mimetype = array(
'doc'=>'application/msword',
'htm'=>'text/html',
'html'=>'text/html',
'jpg'=>'image/jpeg',
'pdf'=>'application/pdf',
'txt'=>'text/plain',
'xls'=>'application/vnd.ms-excel'
);

$p = explode('.', $file);
$pc = count($p);

//send headers
if(($pc > 1) AND isset($mimetype[$p[$pc - 1]]))
{
//display file inside browser
header("Content-type: " . $mimetype[$p[$pc - 1]] . "\n");
}
else
{
//force download dialog
header("Content-type: application/octet-stream\n");
header("Content-disposition: attachment; filename="$file"\n");
}
header("Content-transfer-encoding: binary\n");
header("Content-length: " . filesize($path) . "\n");

//send file contents
$fp=fopen($path, "r");
fpassthru($fp);
?>

Sponsored Links
Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
My experience with downloading files is mostly in Perl, and I haven't dealt with downloading those file types, but here are a couple of things to look at:

Is your server Windows or Unix?

Does the problem vary depending on the clients platform (O/S, browser, etc.)?

Joined: May 2002
Posts: 12
Newbie
Newbie
Offline
Joined: May 2002
Posts: 12
Unix. Redhat 7.2.


The problem so far, has been consistent across client platform

Thanks,

HB

Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
You might want to take a look at the user comments in the php manual.
It helped my a lot some while ago.

http://www.php.net/manual/en/function.header.php

If you can't get it working, i'll can provide some code, i come up with some time ago. Unfortunately, i don't have access to it until the weekend.



Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
hatter
hatter
USA
Posts: 69
Joined: January 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)