Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]upload plików
Forum PHP.pl > Forum > Przedszkole
Ruch Radzionków
witam mam taki problem nie chce mi dodawac avatara mam taki kod php
  1. if($_POST[avatar] <> '')
  2. {
  3. if(is_file("avatar/'.$spra[id].'.gif"))
  4. {
  5. $file = unlink("./avatar/$spra[id].jpg");
  6. }
  7. $nazwa = $_FILES['avatars']['name'];
  8. $rozmiar = $_FILES['avatars']['size'];
  9. $tmp = $_FILES['avatars']['tmp_name'];
  10. $dadoj = "avatar/$spra[id].jpg";
  11. $dodajemy = move_uploaded_file($_FILES["avatar"]["tmp_name"], "avatar/$spra[id].jpg");
  12. if($dodajemy)
  13. {
  14. echo 'dodane';
  15. }
  16. else
  17. {
  18. echo 'problem';
  19. }
  20. }
  21. else
  22. {
  23. echo'<form action="" method="post"><table width="100%">';
  24. if(is_file("avatar/'.$spra[id].'.gif"))
  25. {
  26. echo '<tr><td colspan="2" align="center"><img src="avatar/'.$spra[id].'.gif" style=" width: 75px; height: 85px;"></td></tr>';
  27. $zmienlubdodaj = $lang[avataredytuj];
  28. $submit = $lang[avatarzmien];
  29. }
  30. else
  31. {
  32. echo '<tr><td colspan="2" align="center"><img src="avatar/user.gif" style=" width: 75px; height: 85px;"></td></tr>';
  33. $zmienlubdodaj = $lang[avatardodaj];
  34. $submit = $lang[avatardodaj];
  35. }
  36. echo '<tr>
  37. <td align="right">'.$zmienlubdodaj.'</td>
  38. <td align="center"><input type="file" name="avatar" accept="image/jpeg,image/jpg"></td>
  39. </tr>
  40. <tr>
  41. <td align="center" colspan="2"><input type="submit" name="submit" value="'.$submit.'"></td>
  42. </tr>
  43. </table></form>';
  44. }

nie wiem dlaczego sprawdzałem kilka razy ten kod i nic nie znalazłem żeby było źle. może wy będziecie wiedziec co jest nie tak. z góry dzięki za pomoc
Necsord
Zacznij od:
http://www.php.net/manual/en/features.file...post-method.php
Cytat
Note:
Be sure your file upload form has attribute enctype="multipart/form-data" otherwise the file upload will not work.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.