Einzelnen Beitrag anzeigen

Benutzerbild von littleDave
littleDave

Registriert seit: 27. Apr 2006
Ort: München
556 Beiträge
 
Delphi 7 Professional
 
#6

Re: Autoupgrader soll Datei ueber PHP-Skript laden

  Alt 27. Jun 2008, 11:58
Ich hab mal vor längerer Zeit auch ein Download-Script erstellt und hatte damit bisher keine Probleme. Vielleicht hilft dir das ja:

Code:
$FileName = 'myFile.zip';
$FilePath = '/downloads/';

// Dateiendung auslesen
$extension = strtolower(substr(strrchr($FileName, "."), 1));

// MIME-Typ der Datei-Endung
switch($extension){
    case "asf":    $type = "video/x-ms-asf";               break;
    case "avi":    $type = "video/x-msvideo";              break;
    case "exe":    $type = "application/octet-stream";     break;
    case "mov":    $type = "video/quicktime";              break;
    case "mp3":    $type = "audio/mpeg";                   break;
    case "mpg":    $type = "video/mpeg";                   break;
    case "mpeg":   $type = "video/mpeg";                   break;
    case "rar":    $type = "encoding/x-compress";          break;
    case "txt":    $type = "text/plain";                   break;
    case "wav":    $type = "audio/wav";                    break;
    case "wma":    $type = "audio/x-ms-wma";               break;
    case "wmv":    $type = "video/x-ms-wmv";               break;
    case "zip":    $type = "application/x-zip-compressed"; break;
    default:       $type = "application/force-download";   break;
}

// Einen Bug im IE umgehen: Punkte im Dateinamen sollen durch ein "%2e" ersetzt werden
$header_file = (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
               ? preg_replace('/\./', '%2e', $FileName, substr_count($FileName, '.') - 1)
               : $FileName;
               
// Header-Daten anpassen
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public", false);
header("Content-Description: File Transfer");
header("Content-Type: " . $type);
header("Accept-Ranges: bytes");
header("Content-Disposition: attachment; filename=\"" . $header_file . "\";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($FilePath.$FileName));


// Daten Senden
Jabber: littleDave@jabber.org
in case of 1 is 0 do external raise while in public class of object array else repeat until 1 is 0
  Mit Zitat antworten Zitat