PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Way too braindead this morning.... Simple parsing problem
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Way too braindead this morning.... Simple parsing problem

Réponse
 
LinkBack Outils de la discussion
Vieux 20/01/2008, 16h24   #1
CptDondo
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Way too braindead this morning.... Simple parsing problem

I have a website that shows flash movies. I want to add a download
button that will download the same movie as a wmv file.

I can't for the life of me figure out how to do this....

The sendfile.php is invoked as

http://www.someserver.com/path/to/ph...&image=http://
www.someserver.com/path/to/movies/xyz/movie.flv

what I need to do is to:

take basename of image, replace the .flv wih .wmv, use that as the
filename for 'Content-Disposition: attachment; filename='

replace the http://www.someserver.com/ part with the real path to the
file on the server and use that for the readfile($file) call

The only slighlty complicated thing is that the /xyz/ directory may be
present for some but not for others.

I've been going round and round and the only thing I can think of is that
I have been staring at code too long and haven't had enough coffee....

--Yan
  Réponse avec citation
Vieux 21/01/2008, 00h40   #2
petersprc
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Way too braindead this morning.... Simple parsing problem

You can use the script below:

Use PATH_INFO if your request is get.php/movie.flv or QUERY_STRING if
your request is get.php?movie.flv.

<?

error_reporting(E_ALL | E_STRICT);

function sendWmv()
{
$file = substr(basename($_SERVER['QUERY_STRING']), 0, -4) . '.wmv';
$path = "/my/movies/$file";

if (!file_exists($path)) {
$path = "/my/movies/sub/$file";
if (!file_exists($path)) {
header("{$_SERVER['SERVER_PROTOCOL']} 404 Not Found");
header("Status: 404 Not Found");
echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//
EN"><HTML><HEAD><TITLE>' .
'404 Not Found</TITLE></HEAD><BODY><H1>Not Found</H1>' .
'The requested document was not found.</BODY></HTML>';
return;
}
}

$sz = filesize($path);
header('Content-Type: video/x-ms-wmv');
header("Content-Length: $sz");
header('Content-Disposition: attachment; filename="' .
basename($path) . "\"; size=$sz;");
readfile($path);
}

sendWmv();

?>

On Jan 20, 10:24 am, CptDondo <y...@NsOeSiPnAeMr.com> wrote:
> I have a website that shows flash movies. I want to add a download
> button that will download the same movie as a wmv file.
>
> I can't for the life of me figure out how to do this....
>
> The sendfile.php is invoked as
>
> http://www.someserver.com/path/to/ph.../xyz/movie.flv
>
> what I need to do is to:
>
> take basename of image, replace the .flv wih .wmv, use that as the
> filename for 'Content-Disposition: attachment; filename='
>
> replace thehttp://www.someserver.com/part with the real path to the
> file on the server and use that for the readfile($file) call
>
> The only slighlty complicated thing is that the /xyz/ directory may be
> present for some but not for others.
>
> I've been going round and round and the only thing I can think of is that
> I have been staring at code too long and haven't had enough coffee....
>
> --Yan


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h59.


Édité par : vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,33205 seconds with 10 queries