AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Download - Files von Internetseite

Ein Thema von ATS3788 · begonnen am 1. Apr 2013 · letzter Beitrag vom 13. Apr 2013
 
Benutzerbild von ATS3788
ATS3788

Registriert seit: 18. Mär 2004
Ort: Kriftel
646 Beiträge
 
Delphi XE Starter
 
#16

AW: Download mit javascript jquery

  Alt 11. Apr 2013, 07:56
Danke Valle dachte ich mir schon, habe das von www.html.de
als Antwort bekommen.

Neuer Ansatz neues Glück.

Code:
<!DOCTYPE html>
<html>
<head>
<script>
function loadXMLDoc()
{  //1
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari   //*x
  xmlhttp=new XMLHttpRequest();
  }                                       //*x
else
  {// code for IE6, IE5    //*y
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }                  //*y
xmlhttp.onreadystatechange=function() {   //2
 
 if(xmlhttp.readyState==4){ //3
  switch (xmlhttp.status){  //4
   case 200: {
   var S = xmlhttp.responseText;
    document.getElementById("myDiv").innerHTML= S;
    if (S == "") { document.getElementById("myDiv").innerHTML = "MMMhh"};
    break;
    };
   case 404:
   document.getElementById("myDiv").innerHTML="Download not available !"; break; //(HTTP-Status-Code ist '404')
   case 0:
   document.getElementById("myDiv").innerHTML="Server does not response !"; break; //(HTTP-Status-Code ist '0')
   default:
    log_error("Unknown Error !"); break; //(HTTP-Status-Code ist nicht '200')
  } // 4
 } //  3
}; // 2
xmlhttp.open("GET","download.php",true);
xmlhttp.send();
}; // 1
</script>
</head>
<body>

<h2>AJAX</h2>
<button type="button" onclick="loadXMLDoc()">Request data</button>
<p>Click the button several times to see if the time changes, or if the file is cached.</p>
<div id="myDiv"></div>
</body>
</html>

Zitat:
<?PHP
/**
* Dateien zum Download anbieten
*
* Systemvoraussetzung:
* Linux
* PHP 3, PHP 4, PHP 5
*
* Dateien zum Download anbieten
*
* LICENSE: GNU General Public License (GPL)
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* @category Verschlüsselung
* @author Damir Enseleit <info@selfphp.de>
* @copyright 2001-2006 SELFPHP
* @version $Id: download.php,v 0.10 2006/04/14 13:25:30 des1 Exp $
* @link http://www.selfphp.de
*/

/**
* Erstellt die Navigationsleiste für die einzelnen Seiten
*
* @param string $file Datei, die zum Download steht
* @param string $dir Verzeichnis mit abschließenden Slash (/)
* @param string $type Mime-Type
*
* @return void
*/

function makeDownload($file, $dir, $type)
{

header("Content-Type: $type");

header("Content-Disposition: attachment; filename=\"$file\"");

readfile($dir.$file);

}
// gif - image/gif
// jpg - image/jpeg
// png - image/png
// zip - application/zip
// txt - text/plain

$dir = '/download/';
$type = 'application/zip';
$file = 'Report0.zip';

if(!empty($_GET['file']) && !preg_match('=/=', $_GET['file']))
{
if(file_exists ($dir.$_GET['file']))
{
makeDownload($_GET['file'], $dir, $type);
}
}
?>
OK soweit bin ich nun.
Bekomme sogar xmlhttp.status 200
nur übertragen wird nix.
Hat noch einer eine Idee ?
Martin MIchael

Geändert von ATS3788 (11. Apr 2013 um 08:00 Uhr) Grund: slash vergessen
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:26 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz