OPGELOST, ZIE HIERHey,
Ik heb een probleempje met mijn bestand-share systeem. Ik kan 5 verschillende bestanden uploaden:
- mp3
- wav
- doc
- docx
- pdf
Bij de Word document gaat het fout. Bestanden worden opgeslagen buiten de public_html met timestamp-random code.ext.
Dit is het download scriptje:
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Pragma: public"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Cache-Control: must-revalidate, post-check=0, pre-check=0"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fExt[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]mp3[/COLOR][COLOR= #007700])[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-Type: audio/mpeg"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fExt[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]wav[/COLOR][COLOR= #007700])[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-Type: audio/x-wav"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fExt[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]doc[/COLOR][COLOR= #007700])[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-Type: application/msword"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fExt[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]docx[/COLOR][COLOR= #007700])[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fExt[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]pdf[/COLOR][COLOR= #007700])[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-Type: application/pdf"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$fileRoot[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/str_replace"]str_replace[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]public_html[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]DOCUMENT_ROOT[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]fileUpload/[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-Length: "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fSize[/COLOR][COLOR= #007700]]);[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Content-Disposition: attachment; filename="[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fOriginalName[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-Transfer-Encoding: binary"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/readfile"]readfile[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fileRoot[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fTimestamp[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000].[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$fFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fExt[/COLOR][COLOR= #007700]]);[/COLOR]
?>
$fFetch e.d. kloppen gewoon.
Als ik met deze een .doc bestand probeer te downloaden en die probeer te openen, krijg ik:
Afbeelding niet beschikbaarDe bron kon niet worden geladen (i.imgur.com).Bron openen ↗
Afbeelding niet beschikbaarDe bron kon niet worden geladen (img809.imageshack.us).Bron openen ↗Als ik met deze code een .docx probeer te downloaden, krijg ik dit:
Afbeelding niet beschikbaarDe bron kon niet worden geladen (img22.imageshack.us).Bron openen ↗
Afbeelding niet beschikbaarDe bron kon niet worden geladen (img35.imageshack.us).Bron openen ↗Maar daarna werkt hij wel normaal:
Afbeelding niet beschikbaarDe bron kon niet worden geladen (i.imgur.com).Bron openen ↗Weet iemand hoe ik dit kan oplossen? De andere bestanden werken wel..
En de content-length werkt niet, Opera geeft elke keer andere grootte en in downloads is de grootte onbekend.
toevoeging op 20 mei 2013, 19:47:17:En wav werkt helaas ook niet