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.

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich habe eine Tabelle mit folgender struktur:


Feld  	Typ   	Null  	Standard

id  	int(10) 	Nein  	 

id_content  	int(10) 	Nein  	0 

name  	varchar(255) 	Nein  	 

description  	text 	Nein  	 

file  	longblob 	Nein  	 

nun möchte ich die dateien die ich als blobs gespeichert habe ( sind alles pdf`s) zum download anbieten. so hab ich das gedacht:

      if ( empty( $_GET['id'])) {

         trigger_error( 'missing parameter "id"', E_USER_ERROR);

      }


      $id = $_GET['id'];


      $sql = 'SELECT file,name FROM files WHERE id ='. $id;

      $result = mysql_query( $sql);

      $line = mysql_fetch_assoc( $result);


      $filename = $line['name'];


      header ('Cache-Control: must-revalidate, post-check=0, pre-check=0');

      header ('Content-Description: Download der Datei "'. $filename .'"'); 

      header ('Content-Type: application/octet-stream');

//      header ('Content-Length: ' . filesize($file));

      header ('Content-Disposition: attachment; filename='. $filename);

      exit( $line['file']);   

Der Download startet auch und ich kann die Files herunterladen, aber leider sagt mir mein AdobeReader das er die files nicht öffnen kann.... Fehlermeldung des Readers:

Adobe Readerkonnte "test.pdf" nicht öffnen, da der Dateityp nicht unterstützt wird oder die Datei beschädigt ist...

Muss ich die Binärdaten des Blobs irgendwie konvertieren o.ä.?

Woran könnts noch liegen?

Gruß,

Markus

ich habe die BLOBs mit phpMyAdmin in die DB geladen

Müßte es nicht

echo $line['file'];

heißen?

Denn laut php.net ist exit -> void exit( void )

php.net -> exit()

Gruß Andreas

mein Manual sagt:

zu exit:

exit

(PHP 3, PHP 4 )

exit -- Output a message and terminate the current script

Description

void exit ( [string status])

void exit ( int status)

zu die:

die

die -- Equivalent to exit()

Description

This language construct is equivalent to exit().

Sonst bau Dir doch einen kleinen Upload der beliebige Dateien

in den blob pushen kann. Dann siehst Du ob PHPMyAdmin Probleme

damit hat. Übrigens hatten die alten mySQL Front Versionen auch

Probleme mit Blob's, besonders in zusammenhang mit Dumbs und

Exportierfunktionen.

Gruß Andreas

ich hab den Fehler gefunden.

im output-buffer waren wohl nocht irgendwelche Header drinne die das ganze zerstört haben.

ich hab einfach vor diesem script ein ob_clean() gemacht und schon passts :)

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

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.