captcha vraagje

Gestart doorRobindb84 reacties432 weergaven

85 berichten · pagina 1 van 6

Robindb

Lid · Topicstarter

Berichten
538
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
hallo ik heb probleem
vraagje dit is mijn contact.php
laat maar
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Bestaat ./uploads/.$q[fileName] wel?

Doe eens een file_exists() voordat je met readfile() aan de slag gaat?
0
Robindb

Lid · Topicstarter

Berichten
538
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
eh hoe bedoel je ik heb dit script niet gemaakt
dylanh heeft dat gedaan
dus waar moet ik dit zetten
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
header(Content-Type: application/octet-stream);
        header("Content-Transfer-Encoding: Binary");
        header("Content-disposition: attachment; filename="" . $q[fileName] . """);
        readfile(./uploads/.$q[fileName]);


wordt:

if(file_exists(./uploads/.$q[fileName])) {
        header(Content-Type: application/octet-stream);
        header("Content-Transfer-Encoding: Binary");
        header("Content-disposition: attachment; filename="" . $q[fileName] . """);
        readfile(./uploads/.$q[fileName]);
} else {
        echo "Bestand bestaat niet!";
}
0
Robindb

Lid · Topicstarter

Berichten
538
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Waarom kan ik dan het geuplloade bestand wel via ftp downloaden?
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Omdat PHP geen FTP is. Jij vraagt mogelijk het verkeerde bestand op, zonder te controleren of deze bestaat.
0
Robindb

Lid · Topicstarter

Berichten
538
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
je kan het nu zelf testen
gebruikers naam
robinjoo1
wachtwoord
muis1997
en als ik dan bestand upload zegt hij geupload
doe ik hem downloaden via download knop
dan krijg ik 0 bytes en als ik op delete knop drukt verwijdert hij hem alleen op de pagina zelf niet op de server

toevoeging op 2 mei 2014, 11:54:19:
als ik iets geupload heb krijg ik ook deze tekst

Array ( [file] => Array ( [name] => Snapshot_20140425_3.JPG [type] => image/jpeg [tmp_name] => /tmp/phprPEoSB [error] => 0 [size] => 39538 ) )
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Heb je nou al toegepast wat ik je vroeg? Want bestaat het bestand wel volgens file_exists() zelf? (dus niet volgens FTP).
0
Robindb

Lid · Topicstarter

Berichten
538
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ja dit heb ik

[COLOR= #0000BB]<?php[/COLOR] 
[URL="http://www.php.net/require_once"]require_once[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]])) {[/COLOR]
    [COLOR= #0000BB]$q[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT COUNT(id) AS founds, fileName, baseName FROM files WHERE baseName = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" LIMIT 1"[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$q[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$q[/COLOR][COLOR= #007700]->[/COLOR]fetch_assoc[COLOR= #007700]();[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$q[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]founds[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])  {[/COLOR]
        [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Content-Type: application/octet-stream[/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/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-disposition: attachment; filename=""[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$q[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fileName[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]"""[/COLOR][COLOR= #007700]);[/COLOR] 
        [URL="http://www.php.net/readfile"]readfile[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]./uploads/[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$q[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fileName[/COLOR][COLOR= #007700]]);
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Bestand bestaat niet!"[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700]();
    }
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Location: ./index.php"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700]();
}[/COLOR]
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Waar controleer je nou of het bestand bestaat??????
Nergens!!!!!!!!!!!!

Check mijn code nog maar eens goed.
0
Robindb

Lid · Topicstarter

Berichten
538
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
dit is mijn code

[COLOR= #0000BB]<?php[/COLOR] 
[URL="http://www.php.net/require_once"]require_once[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]config.php[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]])) {[/COLOR]
    [COLOR= #0000BB]$q[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT COUNT(id) AS founds, fileName, baseName FROM files WHERE baseName = "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$mysql[/COLOR][COLOR= #007700]->[/COLOR]real_escape_string[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" LIMIT 1"[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$q[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$q[/COLOR][COLOR= #007700]->[/COLOR]fetch_assoc[COLOR= #007700]();[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$q[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]founds[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])  {[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/file_exists"]file_exists[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]./uploads/[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$q[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fileName[/COLOR][COLOR= #007700]])) {[/COLOR]
        [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Content-Type: application/octet-stream[/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/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Content-disposition: attachment; filename=""[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$q[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fileName[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]"""[/COLOR][COLOR= #007700]);[/COLOR]
        [URL="http://www.php.net/readfile"]readfile[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]./uploads/[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$q[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fileName[/COLOR][COLOR= #007700]]);
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Bestand bestaat niet!"[/COLOR][COLOR= #007700];
}[/COLOR]

        [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700]();
    }
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Location: ./index.php"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700]();
}[/COLOR]
?>
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Blijft het probleem nou nog, dat je bestanden krijgt van 0 bytes?
En waarom alleen een exit op lijn 18?
0
Robindb

Lid · Topicstarter

Berichten
538
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ja via downloaden via pagina zelf wel ja
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Voeg deze header anders eens toe:

header("Content-length: " . filesize(./uploads/.$q[fileName]));


En hoe groot is het bestand zelf op je FTP?
0
Robindb

Lid · Topicstarter

Berichten
538
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
dezelfde groote als wanneer ik hem uploade
heb je teamviewer?
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren