Closed skerbis closed 7 years ago
Würde mich über ein Beispiel freuen .-)
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();
}
Wobei ich mir nicht sicher bin ob exit(); noch benötigt wird
Warum nicht ein passendes MediaManager-Profil anlegen?
Gerne. Gibt es da etwas?
download
,header
, download
, no-cache
dann kann man über das bekannte Schema /imagetypes/download/dateiname.pdf
auch Dateien/Bilder durch den Medienmanager geschleust herunterladen.
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
OK: Ich bin blind... werde ich so ändern... Danke!
oder so
Erledigt in der Version 4.7.4. Danke!
:)
Hey, ging doch fix...
rex_response::sendFile($file,$contenttype, $contentDisposition = 'attachment'); Siehe: http://www.redaxo.org/docs/master/source-class-rex_response.html#70-102