Toon posts:

[PHP] Bestand uploaden..

Pagina: 1
Acties:

Verwijderd

Topicstarter
PHP FILE
----------------------------------------------------------
<form ENCTYPE="multipart/form-data" action="http://www.snipsel.f2s.com/bestand.php" method="post">
<input type="file" name="bestand">
<input type="submit" name="submit" value="Uploaden">
</form>

<?
if(is_uploaded_file($bestand)) {
if($bestand_size > 920480) {
echo "Dit bestand is te groot, wij staan alleen uploads van maximaal 20kb toe !!!";
}
else {
copy($bestand, "ftp://*******:******@ftp.snipsel.f2s.com/www.snipsel.f2s.com/plaatjes/$bestand_name");
echo "Het bestand is succesvol ge-upload";
}
}

else {
echo "Er is iets fout gegaan, probeer het opnieuw."; }
?>

----------------------------------------------------------

ERROR MELDING
----------------------------------------------------------
Warning: open_basedir restriction in effect. File is in wrong directory in /web/sites/317/snipsel/www.snipsel.f2s.com/bestand.php on line 12
Het bestand is succesvol ge-upload
----------------------------------------------------------


Ik kom maar niet uit deze foutmelding wie kan me hiermee helpen?

Mvg. Mark

  • TheRookie
  • Registratie: December 2001
  • Niet online

TheRookie

Nu met R1200RT

Al op de php.net site gezocht ;) zie ook deze pagina

't wordt trouwens ook op prijs gesteld als je
PHP:
1
 en
zonder spaties om je code heenzet :)

  • RobzQ
  • Registratie: Februari 2000
  • Laatst online: 21-12-2020

RobzQ

greedy as a pig

Is je path wel goed?

ftp.snipsel.f2s.com/www.snipsel.f2s.com/plaatjes

Ziet er nogal dubbel uit namelijk?

..so be wary of any man who keeps a pig farm..


Verwijderd

PHP in safe mode -> copy() disabeld -> foutmelding.

Oplossing:
PHP runnen in CGI mode.
Topic starter: Hoe doe ik dat dan?
Patrick83: Je scriptje renamen naar bestnad.cgi
en dit regeltje
#!/usr/bin/php
plaatsen bovenaan je script.

succes.

PS. f2s stopt met gratis hosting m.i.v. 28 Feb. '02.

Verwijderd

Ik gebruik deze zonder file groote controle
PHP:
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
<?
 

if ($submit) { 
if (is_uploaded_file($bestand)) { 
copy($bestand, "files/$bestand_name"); 
echo "Bestand '$bestand_name' met de grootte: $bestand_size bytes is succesvol geupload!"; 
} 

else { 

echo "Er is een fout bij het uploaden van bestand: '$bestand'!"; 

} 
} 

else { 

echo "<form method=\"post\" enctype=\"multipart/form-data\">
  <div align=\"center\">
    <p> 
      <input type=\"file\" name=\"bestand\">
      <br>
      <input type=\"submit\" value=\"Uploaden\" name=\"submit\">
    </p>
  </div>
</form>"; 
} 

?> 
?>

  • itsme
  • Registratie: Februari 2000
  • Niet online
Hmm dat kan ook wel eens werken bij mijn e-smith bak, daar zit een "feature"(Naar mijn mening een bug) in die ervoor zorgt dat je niet in een andere dir files kunt listen/uppen dan de dir waarin de php files zelf staan. (Feature (bug) heet Sandboxing).

Op het moment heb ik dat er gewoon helemaal uit gesloopt ... maar op deze manier is het veel beter ... als het uberhaubt werkt ...

"If God wanted us to have unlimited free energy He would have put a giant fusion reactor in the sky"


Verwijderd

Topicstarter
thnx via dat #!/usr/bin/php en renamen naar .cgi werkt het inderdaad... thnx
Pagina: 1