Uploadsysteem fout

Gestart doorMikek9 reacties47 weergaven

10 berichten · pagina 1 van 1

Mikek

Lid · Topicstarter

Berichten
3.000
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb een upload script

[COLOR= #0000BB]<?PHP[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700])){[/COLOR] 
[COLOR= #0000BB]$locatie[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"images/"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//of een andere map, vergeet niet de w-rechten [/COLOR]
   [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/is_uploaded_file"]is_uploaded_file[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]afbeelding[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]])) 
   {[/COLOR] 
        [COLOR= #FF8000]//controleer grootte [/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]afbeelding[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]size[/COLOR][COLOR= #007700]]>[/COLOR][COLOR= #0000BB]15000[/COLOR][COLOR= #007700]) 
                   {[/COLOR] [COLOR= #FF8000]//bepaal zelf de max. grootte in bytes [/COLOR]
                   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Het bestand is te groot"[/COLOR][COLOR= #007700];[/COLOR] 
                   [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700]; 
                   }[/COLOR] 

        [COLOR= #FF8000]//controleer extensie, voeg maar andere toe [/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/eregi"]eregi[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"((.gif|.jpg)$)"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]afbeelding[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]])) 
                   {[/COLOR] 
                   [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"het bestand is niet van het juiste type"[/COLOR][COLOR= #007700];[/COLOR] 
                   [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700]; 
                   }[/COLOR] 


        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/move_uploaded_file"]move_uploaded_file[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]afbeelding[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]tmp_name[/COLOR][COLOR= #007700]],[/COLOR] 
                               [COLOR= #0000BB]$locatie[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]afbeelding[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]])) 

                  {[/COLOR] 
                  [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]" het bestand kan niet worden verplaatst"[/COLOR][COLOR= #007700];[/COLOR] 
                  [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700]; 
                  }[/COLOR] 

                  [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Uw bestand "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]afbeelding[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]" is geupload"[/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]"Het uploaden is mislukt"[/COLOR][COLOR= #007700]; 
   } 
     

}[/COLOR] 
[URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR] 
?> 
     <form method="post" action="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]PHP_SELF[/COLOR][COLOR= #007700]];[/COLOR] ?>" enctype="multipart/form-data"> 
     <!--Bepaal zelf de maximale grootte in bytes --> 
     <input type="file" name="afbeelding"><br> 
     <input type="submit" name="submit" value="uploaden"> 
     </form> 
[COLOR= #0000BB]<?php[/COLOR] 
     [COLOR= #007700]}[/COLOR] 
?>


dan krijg ik dit
http://miketesthost.woelmuis.nl/index.php

Ik heb 2 problemen de tekst die er boven staat en hij loopt dood als ik upload
0
Mikek

Lid · Topicstarter

Berichten
3.000
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
geen slotje
0
Krm

Lid

Berichten
6.235
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
ten eerste de eerste regel moet en de map images moet je chmodden naar 777
0
Mikek

Lid · Topicstarter

Berichten
3.000
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
hoe kan je chmodden?
0
Anne

Lid

Berichten
2.186
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Habbeurs:
hoe kan je chmodden?

Klik.
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Je moet een verbinding met je SQL maken emo
0
Mikek

Lid · Topicstarter

Berichten
3.000
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als je hem upload staat er dat het gelukt is ofzoiets maar daar wil ik de bestand naam bij hebben bijv bestand.png
0
Berichten
1.950
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nielsie:
Je moet een verbinding met je SQL maken emo
helemaal niet.. Je hoeft geen verbindinge te maken met je database op iets up te loaden
0
Mikek

Lid · Topicstarter

Berichten
3.000
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dat is al opgelost maar mijn andere vraag nog niet (Als je hem upload staat er dat het gelukt is ofzoiets maar daar wil ik de bestand naam bij hebben bijv bestand.png)
0
Anne

Lid

Berichten
2.186
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Habbeurs:
Dat is al opgelost maar mijn andere vraag nog niet (Als je hem upload staat er dat het gelukt is ofzoiets maar daar wil ik de bestand naam bij hebben bijv bestand.png)

Licht eraan waar je de bestanden neerzet en de bestandsnaam vanuit opvraagt volgens mij.

Als je dan met php de bestanden wegzet in een directory moet je het met een array doen:

[COLOR= #0000BB]<?[/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]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]mijn_bestand[/COLOR][COLOR= #007700]]) &&[/COLOR] [COLOR= #0000BB]$_FILES[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]mijn_bestand[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]name[/COLOR][COLOR= #007700]][/COLOR]
?>


En anders dat hij je de naam opvraagt via $fileName en dat je hem dan met echo terughaalt?:

[COLOR= #0000BB]<?
$fileName[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"???.png"[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #FF8000]//dit sla je dan vantevoren daarin op ofzo.[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je hebt het volgende bestand geupload: "[/COLOR]   [COLOR= #007700].[/COLOR]   [COLOR= #0000BB]$fileName[/COLOR]   [COLOR= #007700].[/COLOR]   [COLOR= #DD0000]" blablabla ."[/COLOR][COLOR= #007700];[/COLOR] 
?>


Ik heb eigenlijk niet echt veel ervaring met een upload scripts. Maar misschien heb je hier toch nog een beetje aan..
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