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] Download-Header für JPEG: Bilder haben falsches Format

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich habe ein Skript, in dem Header gesendet werden, um Dateien zu speichern (= Download). Das klappt bisher auch. Nun habe ich das aber mal mit JPEGs ausgeführt.... und es klappt natürlich nicht mehr. Nachdem ich das JPEG downgeloaded habe (also die Anzeige des Download-Fensters geht noch) kommt die Meldung "Can't read file header" oder "Unknown file format"... keine Ahnung, warum... mein Code:


header('Pragma: private');
header('Cache-control: private, must-revalidate');
header("Content-type: image/jpg");

$handle = fopen($filePath . $fileName, "r");
$data = fread($handle, filesize($filePath . $fileName));
fclose($handle);

header("Content-type: ". $ctype);
header("Content-Disposition: attachment; fileName=".$fileName);
echo $data;
[/PHP]

Das JPEG hat natürlich keinen Fehler wenn ich es "normal" öffne.

... hoffentlich weiß jemand weiter.... :(

Das kann vllt. falsch sein:

header("Content-type: image/jpg");
probiers mal mit:
header("Content-type: image/jpeg");

Das hat bei mir schonmal geholfen!

MFG

Das kann vllt. falsch sein:

...

Das hat bei mir schonmal geholfen!

Das ist falsch. Das Dateiformat heißt JPEG (Joint Photographic Experts Group). JPG ist nur eine Windows Abkürzung (Verstümmlung), weil mehr als 3 Buchstaben für eine Dateierweiterung nicht möglich waren.

Na, dann hätten wir ja das Problem.

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.