Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Upload pliku na serwer - bład
Forum PHP.pl > Forum > Przedszkole
bartek4175
Witajcie. Od wczoraj męczę się z tym problemem:
Sorry, there was an error uploading your file.

KOD:
  1. $target_dir = "/home/admin/web/jakastamstrona.pl/public_html/acp/upload/";
  2. $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
  3. $uploadOk = 1;
  4. $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  5. // Check if image file is a actual image or fake image
  6. if(isset($_POST["submit"])) {
  7. $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
  8. if($check !== false) {
  9. echo "File is an image - " . $check["mime"] . ".";
  10. $uploadOk = 1;
  11. } else {
  12. echo '<div class="alert alert-danger">File is not an image.</div>';
  13. $uploadOk = 0;
  14. }
  15. }
  16. // Check if file already exists
  17. //if (file_exists($target_file)) {
  18. // echo "Sorry, file already exists.";
  19. // $uploadOk = 0;
  20. //}
  21. // Check file size
  22. if ($_FILES["fileToUpload"]["size"] > 500000) {
  23. echo '<div class="alert alert-danger">Sorry, your file is too large.</div>';
  24. $uploadOk = 0;
  25. }
  26. // Allow certain file formats
  27. // Check if $uploadOk is set to 0 by an error
  28. if ($uploadOk == 0) {
  29. echo '<div class="alert alert-danger">Sorry, your file was not uploaded.</div>';
  30. // if everything is ok, try to upload file
  31. } else {
  32. if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
  33. echo '<div class="alert alert-success">The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.</div>';
  34. } else {
  35. echo '<div class="alert alert-danger">Sorry, there was an error uploading your file.</div>';
  36. }
  37. }


Folder ma prawa chmod 777 i jest stworzony biggrin.gif

Proszę o pomoc!
Pyton_000
przed if(move_upload... daj

Kod
var_dump($_FILES["fileToUpload"]["tmp_name"], $target_file);die;
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.