FriendsOfREDAXO / Modulsammlung

Ermöglicht es leicht und schnell, einige REDAXO-Module zu installieren.
MIT License
64 stars 15 forks source link

Download Hilfstemplate geht kürzer mit #51

Closed skerbis closed 7 years ago

skerbis commented 8 years ago

rex_response::sendFile($file,$contenttype, $contentDisposition = 'attachment'); Siehe: http://www.redaxo.org/docs/master/source-class-rex_response.html#70-102

olien commented 7 years ago

Würde mich über ein Beispiel freuen .-)

skerbis commented 7 years ago

Ungefähr so:

$fileName = rex_get('fileName', 'string');

if (!file_exists(rex_path::media($fileName)))
{
    rex_redirect(1); // Umleiten zu Fehlerartikel
}
// Redaxo Outputbuffer löschen
rex_response::cleanOutputBuffers();

// Ausgabe des Mediums
$file = rex_path::media().$fileName;
if (file_exists($file)) {
   $contenttype = 'application/octet-stream';
   rex_response::sendFile($file,$contenttype, $contentDisposition = 'attachment');
   exit();
}
skerbis commented 7 years ago

Wobei ich mir nicht sicher bin ob exit(); noch benötigt wird

alxndr-w commented 7 years ago

Warum nicht ein passendes MediaManager-Profil anlegen?

olien commented 7 years ago

Gerne. Gibt es da etwas?

alxndr-w commented 7 years ago

Pflicht

dann kann man über das bekannte Schema /imagetypes/download/dateiname.pdf auch Dateien/Bilder durch den Medienmanager geschleust herunterladen.

Kür

Wem der Pfad nicht gefällt, der wandelt die .htaccess noch ab:

RewriteRule ^media/([^/]*)/([^/]*) %{ENV:BASE}/index.php?rex_media_type=$1&rex_media_file=$2&%{QUERY_STRING} [B]

Download erfolgt dann über /media/download/dateiname.pdf

Oder:

RewriteRule ^download/([^/]*) %{ENV:BASE}/index.php?rex_media_type=download&rex_media_file=$1&%{QUERY_STRING} [B]

Download erfolgt dann direkt über /download/dateiname.pdf

olien commented 7 years ago

OK: Ich bin blind... werde ich so ändern... Danke!

alxndr-w commented 7 years ago

https://github.com/FriendsOfREDAXO/Modulsammlung/issues/47

skerbis commented 7 years ago

oder so

olien commented 7 years ago

Erledigt in der Version 4.7.4. Danke!

alxndr-w commented 7 years ago

:)

olien commented 7 years ago

Hey, ging doch fix...