Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: problem z uploadem
Forum PHP.pl > Forum > Przedszkole
Superhero
podpowiedzcie mi co jest zle z tym skyptem, w ogole nie chce mi robic uploadu:

  1. <? 
  2.  
  3. if ($ile==1) { 
  4.  
  5. print&#092;"<html><head></head> 
  6. <body> 
  7. <form action=&#092;"upl.php?ile=2\" style=\"display:inline;\" method=\"post\" enctype=\"multipart/form-data\"> 
  8. <input type=&#092;"hidden\" name=\"form_sent\" value=\"1\"> 
  9. <br><input name=&#092;"req_file\" type=\"file\"><br> 
  10. </center><br><br> 
  11. <input type=&#092;"submit\" value=\"dodaj ť\"> 
  12. </form> 
  13. </body></html>&#092;"; 
  14.  
  15.  
  16. } elseif ($ile==2) { 
  17.  
  18.  
  19. switch ($uploaded_file['error']) 
  20. { 
  21. case 1: // UPLOAD_ERR_INI_SIZE 
  22. case 2: // UPLOAD_ERR_FORM_SIZE 
  23. print&#092;"1\"; 
  24. break; 
  25.  
  26. case 3: // UPLOAD_ERR_PARTIAL 
  27. print&#092;"2\"; 
  28. break; 
  29.  
  30. case 4: // UPLOAD_ERR_NO_FILE 
  31. print&#092;"3\"; 
  32. break; 
  33.  
  34. default: 
  35. // No error occured, but was something actually uploaded? 
  36. if ($uploaded_file['size'] == 0) 
  37. print&#092;"4\"; 
  38. } 
  39.  
  40.  
  41. if (isset($_POST['form_sent'])) 
  42. { 
  43.  
  44. $uploaded_file = $_FILES['req_file']; 
  45. if (is_uploaded_file($uploaded_file['tmp_name'])) 
  46. { 
  47.  
  48.  
  49. $allowed_types = array('image/jpeg'); 
  50.  
  51. if (!in_array($uploaded_file['type'], $allowed_types)) 
  52. print&#092;"zły format\"; 
  53.  
  54.  
  55. $temp = @move_uploaded_file($uploaded_file['tmp_name'] , '11111111111111.jpg'); 
  56. @chmod('11111111111111.jpg', 0644); 
  57. @unlink('11111111111111.gif'); 
  58. @unlink('11111111111111.png'); 
  59.  
  60. } 
  61. } 
  62. } 
  63. ?>


zwraca problem "4"...
gu35t
  1. <?
  2.  
  3. print &#092;"<html><head></head><body><form action=\"upl.php\" style=\"display:inline;\" method=\"post\" enctype=\"multipart/form-data\">
  4. <input type=&#092;"hidden\" name=\"form_sent\" value=\"1\"><br><input name=\"req_file\" type=\"file\"><br></center><br><br><input type=\"submit\" value=\"dodaj ť\"></form></body></html>\";
  5.  
  6. if (isset($_POST['form_sent']))
  7. {
  8. $uploaded_file = $_FILES['req_file'];
  9. if (is_uploaded_file($uploaded_file['tmp_name']))
  10. {
  11. $allowed_types = array('image/jpeg');
  12. if (!in_array($uploaded_file['type'], $allowed_types)){
  13. die(&#092;"zły format\");
  14. }
  15. else{
  16. $temp = move_uploaded_file($uploaded_file['tmp_name'] , '11111111111111.jpg');
  17. chmod('11111111111111.jpg', 0644);
  18. }
  19. }
  20.  
  21. }
  22. ?>


mi tak dziala. pamietaj ze muisz miec odpowiedzni chmod katalogu.
reszte ktora wywaliem sam uzupelnij
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.