Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Upload pliku na serwer - bład
bartek4175
post
Post #1





Grupa: Zarejestrowani
Postów: 284
Pomógł: 1
Dołączył: 15.08.2013

Ostrzeżenie: (0%)
-----


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!
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
Pyton_000
post
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


przed if(move_upload... daj

Kod
var_dump($_FILES["fileToUpload"]["tmp_name"], $target_file);die;
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 06:13