Hackerboard Wiki HaboBlog
Hackerboard bei Facebook Hackerboard bei Google+ Hackerboard bei Twitter

[HaBo]

 
(Web-) Design und webbasierte Sprachen Tipps & Tricks, Designabgleich, HTML & Javascript, Flash, ASP, PHP, Perl/CGI...

Download statt anzeigen

Diskussion: Download statt anzeigen im Forum (Web-) Design und webbasierte Sprachen, in der Kategorie Web, Network & Multimedia Palace; Anzeige Hallo ! Ich habe einen Link HTML-Code: <a href= "pfad/bild.jpg" > Bild </a> Nun wird mir das Bild angezeigt ...

Like Tree1Likes
  • 1 Post By mime

Antwort
Alt 08.01.12, 22:08   #1 (permalink)
 
Registriert seit: 19.08.04
Dawen Leistung: Addierstift
Likes: 1
Standard Download statt anzeigen

Anzeige

Hallo !

Ich habe einen Link

HTML-Code:
<a href="pfad/bild.jpg">Bild</a>
Nun wird mir das Bild angezeigt und ich möchte es runterladen. Dafür habe ich folgendes

HTML-Code:
<a href="download.php?file=pfad/bild.jpg">Download</a>
Ich möchte, dass das Bild gespeichert werden kann, wenn man auf Download klickt.

Meine download.php sieht wie folgt aus :

PHP-Code:
    header("Cache-Control: no-store, no-cache, must-revalidate");
    
header("Pragma: no-cache");
    
header("Cache-Control: post-check=0, pre-check=0"false);
    
header("Content-type: application/force-download");  
    
header("Content-Disposition: filename=".$_GET['file'].""); 
Nun wird der Download gespeichert, aber das Bild hat nur 2 Byte. Ideen ?
Dawen ist offline   Mit Zitat antworten
Alt 08.01.12, 22:24   #2 (permalink)
Senior Member
 
Benutzerbild von Chakky
 
Registriert seit: 28.10.03
Chakky Leistung: 8086
Chakky eine Nachricht über ICQ schicken
Likes: 110
Standard

PHP-Code:
header("Content-Length: ".filesize("BILD.ENDUNG")); 
häng das mal noch ran an deinen header
__________________
cu
Chakky

we are dreaming in digital
we are living in realtime
we are thinking in binary
we are talking in IP
welcome to our world
Chakky ist offline   Mit Zitat antworten
   
HaBOT
 
- Anzeige -

Werbung ist gerade online    
Alt 08.01.12, 22:53   #3 (permalink)
Themenstarter
 
Registriert seit: 19.08.04
Dawen Leistung: Addierstift
Likes: 1
Standard

Hi !

Immer noch nichts. Ich übergebe immer den kompletten Pfad zur Datei, wie

HTML-Code:
<a href="download.php?file=bilder/große/kunden/bild.jpg">Download</a>
ich habe nun

PHP-Code:
header("Content-Length: ".filesize($_GET['file'])); 
also komplett :

PHP-Code:
    header("Cache-Control: no-store, no-cache, must-revalidate");
    
header("Pragma: no-cache");
    
header("Cache-Control: post-check=0, pre-check=0"false);
    
header("Content-type: application/force-download");  
    
header("Content-Length: ".filesize($_GET['file']));  
    
header("Content-Disposition: filename=".$_GET['file'].""); 
Nun steht da immer noch 0 Bytes !
Dawen ist offline   Mit Zitat antworten
Alt 08.01.12, 23:01   #4 (permalink)
Senior Member
 
Benutzerbild von Chakky
 
Registriert seit: 28.10.03
Chakky Leistung: 8086
Chakky eine Nachricht über ICQ schicken
Likes: 110
Standard

dann prüf mal ob die filesize stimmt und die content length sollte immer das letzte sein was an den header angehangen wird.

welche browser nutzt du um das zu testen?

ansonsten schau mal im php Handbuch da hat einer downloader gebaut:

http://de.php.net/manual/de/function.header.php#102175
__________________
cu
Chakky

we are dreaming in digital
we are living in realtime
we are thinking in binary
we are talking in IP
welcome to our world
Chakky ist offline   Mit Zitat antworten
Alt 09.01.12, 08:27   #5 (permalink)
 
Benutzerbild von she3p
 
Registriert seit: 07.05.07
she3p Leistung: 8086
Likes: 19
Standard

Das Bild gibst du aber nachdem du die headers gesendet hast auch aus oder?

PHP-Code:
// header stuff
echo file_get_contents($_GET['file']); 
__________________
she3p ist offline   Mit Zitat antworten
Alt 09.01.12, 09:23   #6 (permalink)
 
Registriert seit: 12.08.10
mime Leistung: Pentium Imime Leistung: Pentium I
Likes: 30
Standard

Zitat:
Zitat von Dawen Beitrag anzeigen
Meine download.php sieht wie folgt aus :

PHP-Code:
    header("Cache-Control: no-store, no-cache, must-revalidate");
    
header("Pragma: no-cache");
    
header("Cache-Control: post-check=0, pre-check=0"false);
    
header("Content-type: application/force-download");  
    
header("Content-Disposition: filename=".$_GET['file'].""); 
LFI & RFI

Zitat:
Nun wird der Download gespeichert, aber das Bild hat nur 2 Byte. Ideen ?
PHP: readfile - Manual

Micha
she3p likes this.
__________________
http://www.openvas.org
mime ist offline   Mit Zitat antworten
Alt 09.01.12, 11:58   #7 (permalink)
 
Benutzerbild von reaLInsanity
 
Registriert seit: 10.01.06
reaLInsanity Leistung: Facit NTK
reaLInsanity eine Nachricht über ICQ schicken reaLInsanity eine Nachricht über AIM schicken reaLInsanity eine Nachricht über Yahoo! schicken
Likes: 0
Standard

Die Datei an sich eventuell kaputt?
reaLInsanity ist offline   Mit Zitat antworten
Alt 09.01.12, 15:41   #8 (permalink)
Senior Member
 
Registriert seit: 13.07.08
enkore Leistung: K 6-3enkore Leistung: K 6-3enkore Leistung: K 6-3
Likes: 85
Standard

Müsste bei Content-Disposition nich irgendwas mit attachment; filename= oder so stehen=
__________________
"It is the human race! The deterioration of the spirit of man. Man undermining himself, causing a self-willed, self-imposed, self-evident self-destruction."
+++ BREAKING +++ Troll ertrinkt im Planschbecken +++
enkore ist gerade online   Mit Zitat antworten
Alt 11.03.12, 11:52   #9 (permalink)
 
Registriert seit: 27.12.07
simcup Leistung: Facit NTK
Likes: 0
Standard

nenn mich paranoid, aber $_GET['whatever'] ohne prüfung raus zugeben könnte IMHO leichte sicherheitslücken bergen
simcup ist offline   Mit Zitat antworten
Alt 11.03.12, 17:01   #10 (permalink)
 
Benutzerbild von Sleepprogger
 
Registriert seit: 17.10.09
Sleepprogger Leistung: Facit NTK
Likes: 10
Standard

siehe:
Zitat:
Zitat von mime
nicht nur leichte, aber ich gehe einfach davon aus das dies nur Beispielcode war
__________________
Anonymisierungsdienste I
Send from my PC using Firefox...
Sleepprogger ist offline   Mit Zitat antworten
Antwort
   
- Anzeige -

Werbung ist gerade online    

[HaBo] » Web, Network & Multimedia Palace » (Web-) Design und webbasierte Sprachen » PHP Download statt anzeigen
Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

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


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Quit statt Verlassen anzeigen blanc Windows 0 01.02.07 10:49
MAC statt Windows lost Mac OS & Co. 25 05.05.05 16:31
-> "festplatte Nur 120 Statt 160" krimecing Hardware Probleme 5 03.03.05 16:37
2. festplatte : statt 80 gb nur 30 gb gkl Hardware Probleme 7 10.02.04 08:06
4x AGP statt 8x AGP!! A!M Die Problemzone 2 26.01.04 05:44


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61