login  Naam:   Wachtwoord: 
Registreer je!
 Forum

fout met uploaden

Offline Appie_Dijk - 18/08/2005 22:40 (laatste wijziging 19/08/2005 09:00)
Avatar van Appie_DijkLid Wat doe ik fout? :o

ik krijg de volgende foutmelding:
Warning: copy(foto.jpg): failed to open stream: No such file or directory in /home/www/toevoegen_machines.php on line 21


toevoegen_machines.php:

  1. <?php
  2. include("config.php");
  3.  
  4. if(isset($_POST['submit'])) {
  5. $merk = $_POST['merk'];
  6. $type = $_POST['type'];
  7. $urenstand = $_POST['urenstand'];
  8. $algemenestaat = $_POST['algemenestaat'];
  9. $btw = $_POST['btw'];
  10. $prijs = $_POST['prijs'];
  11. $extrainfo1 = $_POST['extrainfo1'];
  12. $extrainfo2 = $_POST['extrainfo2'];
  13. $extrainfo3 = $_POST['extrainfo3'];
  14. $extrainfo4 = $_POST['extrainfo4'];
  15. $extrainfo5 = $_POST['extrainfo5'];
  16. $omschrijving = $_POST['omschrijving'];
  17. $foto = $_POST['foto'];
  18. $map = "fotos/";
  19. $bestand2 = explode("\\", $bestand_name);
  20. $bestand2 = "$bestand2[$laatste]";
  21. copy($foto, "$map$bestand2");
  22.  
  23. mysql_query("INSERT INTO machines (merk, type, bouwjaar, urenstand, algemenestaat, btw, prijs, extrainfo1, extrainfo2, extrainfo3, extrainfo4, extrainfo5, omschrijving, foto) VALUES ('". $merk ."', '". $type ."', '". $bouwjaar ."', '". $urenstand ."', '". $algemenestaat ."', '". $btw ."', '". $prijs ."', '". $extrainfo1 ."', '". $extrainfo2 ."', '". $extrainfo3 ."', '". $extrainfo4 ."', '". $extrainfo5 ."', '". $omschrijving ."', '<img border=\"0\" src=\"http://www.mijnsite.nl/fotos/". $foto ."\">')");
  24.  
  25. echo "". $merk ." ". $type ." is toegevoegd!<br>";
  26. echo "<a href='admin.php'>Ga terug!</a><br>";
  27. echo "<a href='toevoegen_machine.php'>Nog een machine toevoegen!</a><br>";
  28.  
  29.  
  30. } else {
  31. ?>
  32.  
  33. <style type="text/css">
  34. body, td {
  35. font-family: tahoma;
  36. font-size: 10pt;
  37. }
  38. </style>
  39. <form action="" method="post">
  40. <table width="600">
  41. <tr><td width="600" bgcolor="#BBE100" colspan="5"><b>Merk: <input name="merk" type="text" value="" maxlength="250"></b></td></tr>
  42. <tr><td width="600" bgcolor="#BBE100" colspan="5"><b>Type: <input name="type" type="text" value="" maxlength="250"></b></td></tr>
  43. <tr><td width="600" colspan="5" bgcolor="#BBE100"><b>Omschrijving:
  44. <input name="omschrijving" type="text" value="" maxlength="250"></b></td></tr>
  45. <tr><td width="225" rowspan="13" valign="top">Bestand: <input type=file name=foto></td>
  46. <td width="10">&nbsp;</td>
  47. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  48. <b>Bouwjaar</b></td>
  49. <td width="10" align="center"><b>:</b></td>
  50. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="bouwjaar" type="text" value="" maxlength="4"></td></tr>
  51. <tr><td width="10">&nbsp;</td>
  52. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  53. <b>Urenstand</b></td>
  54. <td width="10" align="center"><b>:</b></td>
  55. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="urenstand" type="text" value="" maxlength="10"></td></tr>
  56. <tr><td width="10">&nbsp;</td>
  57. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  58. <b>Algemene staat</b></td>
  59. <td width="10" align="center"><b>:</b></td>
  60. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="algemenestaat" type="text" value="" maxlength="50"></td></tr>
  61. <tr><td width="10">&nbsp;</td>
  62. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  63. <b>BTW / Marge</b></td>
  64. <td width="10" align="center"><b>:</b></td>
  65. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="btw" type="text" value="" maxlength="10"></td></tr>
  66. <tr><td width="10">&nbsp;</td>
  67. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  68. <b>Prijs excl.</b></td>
  69. <td width="10" align="center"><b>:</b></td>
  70. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="prijs" type="text" value="" maxlength="10"></td></tr>
  71.  
  72. <tr>
  73. <td width="10">&nbsp;</td>
  74. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  75. <b>Extra informatie</b></td>
  76. <td width="10" align="center"><b>:</b></td>
  77. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="extrainfo1" type="text" value="" maxlength="250"></td>
  78. </tr>
  79.  
  80. <tr><td width="10">&nbsp;</td>
  81. <td width="155">&nbsp;</td>
  82. <td width="10" align="center">&nbsp;</td>
  83. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="extrainfo2" type="text" value="" maxlength="250"></td></tr>
  84.  
  85. <tr><td width="10">&nbsp;</td>
  86. <td width="155">&nbsp;</td>
  87. <td width="10" align="center">&nbsp;</td>
  88. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="extrainfo3" type="text" value="" maxlength="250"></td></tr>
  89.  
  90. <tr><td width="10">&nbsp;</td>
  91. <td width="155">&nbsp;</td>
  92. <td width="10" align="center">&nbsp;</td>
  93. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="extrainfo4" type="text" value="" maxlength="250"></td></tr>
  94.  
  95. <tr><td width="10">&nbsp;</td>
  96. <td width="155">&nbsp;</td>
  97. <td width="10" align="center">&nbsp;</td>
  98. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="extrainfo5" type="text" value="" maxlength="250"></td></tr>
  99. <tr><td colspan="4">&nbsp;</td></tr>
  100. <tr><td colspan="4"><input type="submit" value="Voeg Toe!" name="submit"><input type="reset" value="Leeg Maken!"></td></tr>
  101. </table>
  102. </form>
  103. <?
  104. echo "<a href='admin.php'>Ga terug!</a><br>";
  105. }
  106. ?>

7 antwoorden

Gesponsorde links
Offline DRUNK - 18/08/2005 22:46 (laatste wijziging 18/08/2005 22:48)
Avatar van DRUNK PHP gevorderde Waarom post je AL die HTML? De foutmelding geeft iets over copy(), hier moet je dus gaan zoeken, is de file wel echt geupload? Hoe benader je die geuploade file?
Heb je de voorbeelden van PHP.net (http://www.php.net/manual/en/features.file-upload.php) al bestudeerd, de uitleg gelezen?

succes!

PS: code-tags maken het lezen iets gemakkelijker ;)
Offline jarro - 18/08/2005 22:46
Avatar van jarro HTML interesse $bestand2 = "$bestand2[$laatste]";

moet dit niet zijn:
$bestand2 = "$bestand2[laatste]"; ??

en mag dit wel
"$map$bestand2" moet dat niet "".$map."".$bestand2."" zijn?

of zeg ik égt iets heel doms?
:$
Offline Appie_Dijk - 18/08/2005 23:05
Avatar van Appie_Dijk Lid @Drunk: wordt niet echt wijzer van die php-manual... ik snap niet wat er fout is :S (nu ben ik ook nog niet zo super vertrouwd met php)

@Jarro: maakt geen verschil of ik dat erneer zet of mijn code
Offline Yoaz - 18/08/2005 23:08 (laatste wijziging 18/08/2005 23:12)
Avatar van Yoaz Lid "$map$bestand2" moeten inderdaad buiten die quotes staan.
kijk dit eens: http://www.site...amp;id=184
of deze:
http://nl2.php.net/manual/en/function.copy.php
Offline TFOL - 18/08/2005 23:26
Avatar van TFOL PHP beginner zet dit je form tag: enctype="multipart/form-data"

en als je iets wil uploaden gebruik je dit:

  1. <?php
  2.  
  3. $tmp_bestand = $_FILES['uploadveldnaam']['tmp_name'];
  4. $bestand = $_FILES['uploadveldnaam']['name'];
  5. $locatie = "Map waar foto is moet komen";
  6.  
  7. move_uploaded_file($tmp_bestand, $locatie."/".$bestand);
  8.  
  9. ?>
Offline Appie_Dijk - 19/08/2005 11:34 (laatste wijziging 19/08/2005 12:02)
Avatar van Appie_Dijk Lid @TFOL

je bedoelt zo??? -ik krijg nu geen foutmelding meer maar hij upload ook niets?-

  1. <?php
  2. include("config.php");
  3.  
  4. if(isset($_POST['submit'])) {
  5. $merk = $_POST['merk'];
  6. $type = $_POST['type'];
  7. $urenstand = $_POST['urenstand'];
  8. $algemenestaat = $_POST['algemenestaat'];
  9. $btw = $_POST['btw'];
  10. $prijs = $_POST['prijs'];
  11. $extrainfo1 = $_POST['extrainfo1'];
  12. $extrainfo2 = $_POST['extrainfo2'];
  13. $extrainfo3 = $_POST['extrainfo3'];
  14. $extrainfo4 = $_POST['extrainfo4'];
  15. $extrainfo5 = $_POST['extrainfo5'];
  16. $omschrijving = $_POST['omschrijving'];
  17. $foto = $_POST['foto'];
  18. $tmp_bestand = $_FILES['uploadveldnaam']['tmp_name'];
  19. $bestand = $_FILES['uploadveldnaam']['name'];
  20. $locatie = "fotos";
  21.  
  22. move_uploaded_file($tmp_bestand, $locatie."/".$bestand);
  23.  
  24. mysql_query("INSERT INTO machines (merk, type, bouwjaar, urenstand, algemenestaat, btw, prijs, extrainfo1, extrainfo2, extrainfo3, extrainfo4, extrainfo5, omschrijving, foto) VALUES ('". $merk ."', '". $type ."', '". $bouwjaar ."', '". $urenstand ."', '". $algemenestaat ."', '". $btw ."', '". $prijs ."', '". $extrainfo1 ."', '". $extrainfo2 ."', '". $extrainfo3 ."', '". $extrainfo4 ."', '". $extrainfo5 ."', '". $omschrijving ."', '<img border=\"0\" src=\"http://www.mijnsite.nl/fotos/". $foto ."\">')");
  25.  
  26. echo "". $merk ." ". $type ." is toegevoegd!<br>";
  27. echo "<a href='admin.php'>Ga terug!</a><br>";
  28. echo "<a href='toevoegen_machine.php'>Nog een machine toevoegen!</a><br>";
  29.  
  30.  
  31. } else {
  32. ?>
  33.  
  34. <style type="text/css">
  35. body, td {
  36. font-family: tahoma;
  37. font-size: 10pt;
  38. }
  39. </style>
  40. <form action="" method="post" enctype="multipart/form-data">
  41. <table width="600">
  42. <tr><td width="600" bgcolor="#BBE100" colspan="5"><b>Merk: <input name="merk" type="text" value="" maxlength="250"></b></td></tr>
  43. <tr><td width="600" bgcolor="#BBE100" colspan="5"><b>Type: <input name="type" type="text" value="" maxlength="250"></b></td></tr>
  44. <tr><td width="600" colspan="5" bgcolor="#BBE100"><b>Omschrijving:
  45. <input name="omschrijving" type="text" value="" maxlength="250"></b></td></tr>
  46. <tr><td width="225" rowspan="13" valign="top">Bestand: <input type=file name=foto></td>
  47. <td width="10">&nbsp;</td>
  48. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  49. <b>Bouwjaar</b></td>
  50. <td width="10" align="center"><b>:</b></td>
  51. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="bouwjaar" type="text" value="" maxlength="4"></td></tr>
  52. <tr><td width="10">&nbsp;</td>
  53. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  54. <b>Urenstand</b></td>
  55. <td width="10" align="center"><b>:</b></td>
  56. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="urenstand" type="text" value="" maxlength="10"></td></tr>
  57. <tr><td width="10">&nbsp;</td>
  58. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  59. <b>Algemene staat</b></td>
  60. <td width="10" align="center"><b>:</b></td>
  61. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="algemenestaat" type="text" value="" maxlength="50"></td></tr>
  62. <tr><td width="10">&nbsp;</td>
  63. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  64. <b>BTW / Marge</b></td>
  65. <td width="10" align="center"><b>:</b></td>
  66. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="btw" type="text" value="" maxlength="10"></td></tr>
  67. <tr><td width="10">&nbsp;</td>
  68. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  69. <b>Prijs excl.</b></td>
  70. <td width="10" align="center"><b>:</b></td>
  71. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="prijs" type="text" value="" maxlength="10"></td></tr>
  72.  
  73. <tr>
  74. <td width="10">&nbsp;</td>
  75. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  76. <b>Extra informatie</b></td>
  77. <td width="10" align="center"><b>:</b></td>
  78. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="extrainfo1" type="text" value="" maxlength="250"></td>
  79. </tr>
  80.  
  81. <tr><td width="10">&nbsp;</td>
  82. <td width="155">&nbsp;</td>
  83. <td width="10" align="center">&nbsp;</td>
  84. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="extrainfo2" type="text" value="" maxlength="250"></td></tr>
  85.  
  86. <tr><td width="10">&nbsp;</td>
  87. <td width="155">&nbsp;</td>
  88. <td width="10" align="center">&nbsp;</td>
  89. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="extrainfo3" type="text" value="" maxlength="250"></td></tr>
  90.  
  91. <tr><td width="10">&nbsp;</td>
  92. <td width="155">&nbsp;</td>
  93. <td width="10" align="center">&nbsp;</td>
  94. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="extrainfo4" type="text" value="" maxlength="250"></td></tr>
  95.  
  96. <tr><td width="10">&nbsp;</td>
  97. <td width="155">&nbsp;</td>
  98. <td width="10" align="center">&nbsp;</td>
  99. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100"><input name="extrainfo5" type="text" value="" maxlength="250"></td></tr>
  100. <tr><td colspan="4">&nbsp;</td></tr>
  101. <tr><td colspan="4"><input type="submit" value="Voeg Toe!" name="submit"><input type="reset" value="Leeg Maken!"></td></tr>
  102. </table>
  103. </form>
  104. <?
  105. echo "<a href='admin.php'>Ga terug!</a><br>";
  106. }
  107. ?>
Offline TFOL - 19/08/2005 14:00
Avatar van TFOL PHP beginner - Als je iets wil uploaden gebruik je dit als input-tag gebruiken:
<input type="file" name="bestand" />

- Dit gebruik je om het te verwerken:
  1. <?php
  2.  
  3. $tmp_bestand = $_FILES['bestand']['tmp_name'];
  4. $bestand = $_FILES['bestand']['name'];
  5. $locatie = "fotos";
  6.  
  7. move_uploaded_file($tmp_bestand, $locatie."/".$bestand);
  8.  
  9. ?>
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2025 Sitemasters.be - Regels - Laadtijd: 0.228s