Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

PHP-Downloadscript

Empfohlene Antworten

Veröffentlicht

hi,

ich habe mir ein Download-Script gebastelt, zum teil aus Inet Quellen, zum Teil selber.

Anfangs hatte ich das Problem das er alle Dateien als zwangs-Download behandelt...

mit

$header="filename=".$filename.";";

anstatt

$header="Content-Disposition: attachment; filename=".$filename.";";

lädt er zumindest Bilder jetzt wieder in einem browserfenster, wie es seinsollte...aber einfache txt Dateien werden immernoch zwangsgeladen...

// Mime Type
switch( $file_extension )
{
case "txt": $ctype="application/txt"; break;
case "pdf": $ctype="application/pdf"; break;
case "zip": $ctype="application/zip"; break;
case "gif": $ctype="image/gif"; break;
case "png": $ctype="image/png"; break;
case "jpeg":
case "jpg": $ctype="image/jpg"; break;

default: $ctype="application/force-download";
}

// Write Header
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");

// Header: Mime Type
header("Content-Type: ".$ctype);

// "Content-Disposition: attachment; filename=".$filename;
header("filename=".$filename);
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".$len);

// Content-Output
@readfile($file);[/PHP]

ich wollte eigentlich auf eine Weiche verzichten die dann z.B. echo $content;

oder so macht...k.A. wie es bei weiteren Dateitypen aussieht...

ich kenne die sicherheitsbedenken bei solchen Scripts :) aber das habe ich abgefangen...hab' jetzt aber nur den relevanten Teil des Scripts gepostet

Hi,


$header="Content-Disposition: [b]inline[/b]; filename=".$filename.";";

Gruß Jaraz

k, danke.

Hat funktioniert.

Weißt du wo das festgelegt ist ?

auf www.php.net habe ich nur die Spezifikation für http-insgesamt gefunden....etwas umfangreiche lektüre für sowas

Weißt du wo das festgelegt ist ?

Das hat mit PHP nichts zu tun. Du solltest eher bei HTTP-Spezifikationen suchen, da "Inline" (frei übersetzt: drinnen) und "attachement" (Anhang) auch andersow gibt. E-Mail ist ein gutes Beispiel. Du kannst da Bilder nämlich auch Inline (also der Empfänger sieht sie, wenn er die Nachricht liest) oder als Attachement (das Bild ist nur als Anhang dabei) verschicken.

EDIT:

Mit "header" änderst/erweiterst du (wie es der Name schon sagt) nur den HTTP-Header, der von Server abgeschickt wird.

EDIT2:

Content-Disposition is an extension to the MIME protocol that describes the content of the message and provides instructions about how the content is to be displayed.

http://www.ietf.org/rfc/rfc2183.txt

http://www.ietf.org/rfc/rfc1806.txt

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.