Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Wrzucanie plikow na serwer FTP z poziomu strony
Forum PHP.pl > Forum > Przedszkole
bolus150
Witam! mam taki problem, mianowicie. Czy ktos mi moze sprawdzic ten program. Moje zalozenie bylo takie zeby z poziomu strony www wrzucac pliki na serwer FTP na yoyo.
Oto moj program:
  1.  
  2. <?php
  3.  
  4. $site_name = $_SERVER['88.198.224.154'];
  5. $url_dir = "http://test1551.yoyo.pl".$_SERVER['88.198.224.154'].dirname($_SERVER['PHP_SELF']);
  6. $url_this = "http://test.yoyo.pl".$_SERVER['88.198.224.154'].$_SERVER['PHP_SELF'];
  7.  
  8. $upload_dir = "upload_files/";
  9. $upload_url = $url_dir."/upload_files/";
  10. $message ="";
  11.  
  12. //create upload_files directory if not exist
  13. //If it does not work, create on your own and change permission.
  14. if (!is_dir("upload_files")) {
  15. die ("upload_files directory doesn't exist");
  16. }
  17.  
  18. if ($_FILES['userfile']) {
  19. $message = do_upload($upload_dir, $upload_url);
  20. }
  21. else {
  22. $message = "Invalid File Specified.";
  23. }
  24.  
  25. print $message;
  26.  
  27. function do_upload($upload_dir, $upload_url) {
  28.  
  29. $temp_name = $_FILES['userfile']['tmp_name'];
  30. $file_name = $_FILES['userfile']['name'];
  31. $file_type = $_FILES['userfile']['type'];
  32. $file_size = $_FILES['userfile']['size'];
  33. $result = $_FILES['userfile']['error'];
  34. $file_url = $upload_url.$file_name;
  35. $file_path = $upload_dir.$file_name;
  36.  
  37. //File Name Check
  38. if ( $file_name =="") {
  39. $message = "Invalid File Name Specified";
  40. return $message;
  41. }
  42. //File Size Check
  43. else if ( $file_size > 500000) {
  44. $message = "The file size is over 500K.";
  45. return $message;
  46. }
  47. //File Type Check
  48. else if ( $file_type == "text/plain" ) {
  49. $message = "Sorry, You cannot upload any script file" ;
  50. return $message;
  51. }
  52.  
  53. $result = move_uploaded_file($temp_name, $file_path);
  54. $message = ($result)?"File url <a href=$file_url>$file_url</a>" :
  55. "Somthing is wrong with uploading a file.";
  56.  
  57. return $message;
  58. }
  59. ?>
l3l0
Poczytaj sobie:
http://forum.php.pl/lofiversion/index.php/t105285.html

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.