header Content-Disposition

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • header Content-Disposition

    Hi Leute, wie die überschrift sagt, habe ich ein kleines Prob. Mit meinem Script wird in firefox der Inahlt der zu downloadenen Datei als Text auf der Page ausgegeben.
    Weiß jeman woran es liegen könnte?
    PHP-Code:
    <?php
    if(isset($path)){ 
    $owner "meinedomain.de";
    if (
    strchr("$HTTP_REFERER","$owner"))  {

    $filetype=explode(".",$dl);
     if (
    $fileype[3] == "zip")
    {
      
    header("Content-type: application/zip");
    }
    if (
    $filetype[3] == "rar")
    {
      
    header("Content-type: application/x-rar-compressed");
    }
    if (
    $filetype[3] == "exe")
    {
      
    header("Content-type: application/octet-stream");

    if (
    $filetype[3] == "gz")
    {
      
    header("Content-type: application/x-gzip");

    if (
    $filetype[3] == "gz")
    {
      
    header("Content-type: application/x-gzip");

    if (
    $filetype[3] == "mpg")
    {
      
    header("Content-type: video/mpeg");

    if (
    $filetype[3] == "mpeg")
    {
      
    header("Content-type: video/mpeg");

    header("Content-Disposition: attachment; filename=$dl");
    @
    readfile($dl);


    }
    ?>
    $dl ist URL zur Datei zum Beispiel:
    http://www.meinedomain.de/files/unterordner/datei.zip
    Also wird von daher auch $filetype[3] stimmen. Ich bin am verzweifeln und werde bestimmt nicht einpennen, wenn ich das nicht hikriege

  • #2
    Ahh endlich, ich habs hinbekommen, sorry, hab aber auf
    http://php3.de/manual/de/function.readfile.php
    die richtige Lösung gefunden. Ich poste mal, falls es jemand irgendwann mal brauchen sollte:

    PHP-Code:
    <?php
    if(isset($path)){ 
    $owner "domain.de";
    if (
    strchr("$HTTP_REFERER","$owner"))  {

    $filetype=explode(".",$dl);
     if (
    $fileype[3] == "zip")
    {
      
    header("Content-type: application/zip");
    }
    if (
    $filetype[3] == "rar")
    {
      
    header("Content-type: application/x-rar-compressed");
    }
    if (
    $filetype[3] == "exe")
    {
      
    header("Content-type: application/octet-stream");

    if (
    $filetype[3] == "gz")
    {
      
    header("Content-type: application/x-gzip");

    if (
    $filetype[3] == "mpg")
    {
      
    header("Content-type: video/mpeg");

    if (
    $filetype[3] == "mpeg")
    {
      
    header("Content-type: video/mpeg");


    header("Content-Disposition: attachment; filename=".basename($dl).";");
    @
    readfile($dl);


    }
    ?>
    nun kann ich ruhig schlafen :P
    Zuletzt geändert von archie; 15.09.2004, 09:02.

    Kommentar


    • #3
      @archie
      ok, also funktioniert es demnach im IE aber nicht im Firefox?
      Wüßte nicht dass der allgemein Probleme hat.

      PHP-Code:
      $filetype=explode(".",$dl);
      if (
      $fileype[3] == "zip"
      wie kommst Du auf $fileype[3]? In Deinem Fall kann es jetzt natürlich passen aber ansonsten nimm doch $fileype[count($fileype)-1] wenn Du das letzte Element haben möchtest.

      EDIT:
      da war ich zu langsam
      [Test] MySQL cli Emulator

      Kommentar

      Lädt...
      X