Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [HTML][PHP]upload php
bolus150
post
Post #1





Grupa: Zarejestrowani
Postów: 150
Pomógł: 0
Dołączył: 14.06.2008

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


witam! Ma moze ktos napisany program do uploadowania plikow na serwer, np: yoyo. Mam napisany formularz w HTML i pod niego chcialbym program do wrzucania plikow

Oto moj formularz

  1. <script language="javascript" src="filecabinet.js"></script>
  2. <br<br><B>Download</b>
  3. <form method="post" action="upload.php" enctype="multipart/form-data">
  4. <input type="hidden" name="MAX_FILE_SIZE" value="30000">
  5.  
  6. Wybierz plik który chcesz umiescic na serwerze:<br>
  7.  
  8. <input type="file" name="pliczek" size="40"><br>
  9. <input type="submit" value="Wgraj plik">
  10.  
  11. </div>
  12.  
  13. </head>
  14. </body>
  15. </html>

Prosze o pomoc, bo juz mam mentlik w glowie..;p
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 9)
Blame
post
Post #2





Grupa: Zarejestrowani
Postów: 678
Pomógł: 124
Dołączył: 26.09.2009

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


Gotowca nie dostaniesz, ale: http://webmade.org/kursy-online/upload-kurs-php.php
Go to the top of the page
+Quote Post
Soulast
post
Post #3





Grupa: Zarejestrowani
Postów: 133
Pomógł: 6
Dołączył: 26.10.2009

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


Ależ są gotowce również wystarczy poszperać na google a tym czasem mogę polecić..:

http://www.tizag.com/phpT/fileupload.php?M...ile=freebl3.chk
Go to the top of the page
+Quote Post
bolus150
post
Post #4





Grupa: Zarejestrowani
Postów: 150
Pomógł: 0
Dołączył: 14.06.2008

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


no kurde, jestem tak ciemny, ze nawet nie iwem co z tym zrobic..;p moglbys troszke jasniej? jak to zrobic zeby sie laczylo z serwerem przede wszystkim bym chcial wiedziec

jak zrobic to zeby dzialalo? jak to wszystko polaczyc?

  1. // Where the file is going to be placed
  2. $target_path = "uploads/";
  3.  
  4. /* Add the original filename to our target path.
  5. Result is "uploads/filename.extension" */
  6. $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);


  1. $target_path = "uploads/";
  2.  
  3. $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
  4.  
  5. if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
  6. echo "The file ". basename( $_FILES['uploadedfile']['name']).
  7. " has been uploaded";
  8. } else{
  9. echo "There was an error uploading the file, please try again!";
  10. }
  11.  


z HTML

  1.  
  2. <br<br><B>Download</b>
  3. <form method="post" action="upload.php" enctype="multipart/form-data">
  4. <input type="hidden" name="MAX_FILE_SIZE" value="30000">
  5.  
  6. Wybierz plik który chcesz umiescic na serwerze:<br>
  7.  
  8. <input type="file" name="pliczek" size="40"><br>
  9. <input type="submit" value="Wgraj plik">
  10.  
  11. </div>
  12.  
  13. </head>
  14. </body>
  15. </html>
Go to the top of the page
+Quote Post
Soulast
post
Post #5





Grupa: Zarejestrowani
Postów: 133
Pomógł: 6
Dołączył: 26.10.2009

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


Spróbuj tego oraz pamiętaj że twój folder docelowy musi posiadać chmod 777

  1. <br><B>Download</b>
  2. <form enctype="multipart/form-data" action="upload.php" method="POST">
  3. <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
  4. Wybierz plik do uploadu:
  5. <input name="uploadedfile" type="file" /><br />
  6. <input type="submit" value="Upload File" />
  7. </form>
  8. <?
  9. // Gdzie plik ma byc zamieszczony
  10. $target_path = "uploads/";
  11.  
  12. /* Add the original filename to our target path.
  13. Result is "uploads/filename.extension" */
  14. $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
  15.  
  16. $target_path = "uploads/";
  17.  
  18. $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
  19.  
  20. if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
  21. echo "The file ". basename( $_FILES['uploadedfile']['name']).
  22. " has been uploaded";
  23. } else{
  24. echo "There was an error uploading the file, please try again!";
  25. }
  26. ?>
  27.  
  28. </head>
  29. </body>
  30. </html>


Ten post edytował Soulast 13.01.2010, 20:25:46
Go to the top of the page
+Quote Post
bolus150
post
Post #6





Grupa: Zarejestrowani
Postów: 150
Pomógł: 0
Dołączył: 14.06.2008

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


Czyli powoli. Musze miec na FTP folder o nazwie chmod 777 <= i tam mi bedzie wrzucac te pliki tak?
Brakuje mi upload.php..;/
Go to the top of the page
+Quote Post
Soulast
post
Post #7





Grupa: Zarejestrowani
Postów: 133
Pomógł: 6
Dołączył: 26.10.2009

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


Cytat(bolus150 @ 13.01.2010, 20:58:04 ) *
Czyli powoli. Musze miec na FTP folder o nazwie chmod 777 <= i tam mi bedzie wrzucac te pliki tak?
Brakuje mi upload.php..;/


upload.php jest to wlaśnie plik gdzie znajduje się ten cały skrypt uploadu oraz chmod 777 nie jest nazwą folderu tylko dostępem do niego mozesz zmienic ten dostep przy pomocy fireftp (wtyczka firefox) przyklad :prawym mysza a nastepmnie w permission wpisz 0777 czy totalcomandera zalezy czego uzywasz.. Jest to poprostu dostęp do foldera 777 umożliwia wgrywanie plików oraz ich zmiane w danym folderze ze strony severa..
Go to the top of the page
+Quote Post
bolus150
post
Post #8





Grupa: Zarejestrowani
Postów: 150
Pomógł: 0
Dołączył: 14.06.2008

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


czyli ten plik co mi napisales mam nazwac upload.php, nadal nie jaze o co chodzi z tym 777..;/ moj adres ftp jest 78.47.222.220 gdzie go trzeba wpisac i haslo zeby sie laczylo?
Go to the top of the page
+Quote Post
Soulast
post
Post #9





Grupa: Zarejestrowani
Postów: 133
Pomógł: 6
Dołączył: 26.10.2009

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


nie musi byc upload.php nazwij go jak tylko zechcesz tylko pamietaj aby zmienic w skrypcie upload.php na jaki tam zmienileś..

co do chmod to zapraszam tutaj :

http://dokumentacja.amm.net.pl/entry/155/

Go to the top of the page
+Quote Post
bolus150
post
Post #10





Grupa: Zarejestrowani
Postów: 150
Pomógł: 0
Dołączył: 14.06.2008

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


Dobra mam to wszystko, teraz pytanie jak zrobic zeby bylo to widac na stronie;
  1. <?php
  2.  
  3. $site_name = $_SERVER['HTTP_HOST'];
  4. $url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
  5. $url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
  6.  
  7. $upload_dir = "upload_files/";
  8. $upload_url = $url_dir."/upload_files/";
  9. $message ="";
  10.  
  11. //create upload_files directory if not exist
  12. //If it does not work, create on your own and change permission.
  13. if (!is_dir("upload_files")) {
  14. die ("upload_files directory doesn't exist");
  15. }
  16.  
  17. if ($_FILES['userfile']) {
  18. $message = do_upload($upload_dir, $upload_url);
  19. }
  20. else {
  21. $message = "Invalid File Specified.";
  22. }
  23.  
  24. print $message;
  25.  
  26. function do_upload($upload_dir, $upload_url) {
  27.  
  28. $temp_name = $_FILES['userfile']['tmp_name'];
  29. $file_name = $_FILES['userfile']['name'];
  30. $file_type = $_FILES['userfile']['type'];
  31. $file_size = $_FILES['userfile']['size'];
  32. $result = $_FILES['userfile']['error'];
  33. $file_url = $upload_url.$file_name;
  34. $file_path = $upload_dir.$file_name;
  35.  
  36. //File Name Check
  37. if ( $file_name =="") {
  38. $message = "Invalid File Name Specified";
  39. return $message;
  40. }
  41. //File Size Check
  42. else if ( $file_size > 500000) {
  43. $message = "The file size is over 500K.";
  44. return $message;
  45. }
  46. //File Type Check
  47. else if ( $file_type == "text/plain" ) {
  48. $message = "Sorry, You cannot upload any script file" ;
  49. return $message;
  50. }
  51.  
  52. $result = move_uploaded_file($temp_name, $file_path);
  53. $message = ($result)?"File url <a href=$file_url>$file_url</a>" :
  54. "Somthing is wrong with uploading a file.";
  55.  
  56. return $message;
  57. }
  58. ?>
  59. <form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">
  60. Upload Image<input type="file" id="userfile" name="userfile">
  61. <input type="submit" name="upload" value="Upload">
  62. </form>
  63.  

i dodaje do folderu a jak zrobic zeby pokazywalo na stronie co dodalo?

i zeby szlo pobrac to ze strony..;p

Moglby mi to ktos polaczyc?

  1. <script language="javascript" src="filecabinet.js"></script>
  2.  
  3. <br><B>Download</b>
  4. <form enctype="multipart/form-data" action="simple_upload.php" method="POST">
  5. <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
  6. Wybierz plik do uploadu:
  7. <input name="uploadedfile" type="file" /><br />
  8. <input type="submit" value="Upload File" />
  9. </form>
  10. <?
  11. // Gdzie plik ma byc zamieszczony
  12. $target_path = "78.47.222.220";
  13.  
  14. /* Add the original filename to our target path.
  15. Result is "uploads/filename.extension" */
  16. $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
  17.  
  18. $target_path = "15-3bti.yoyo.pl";
  19.  
  20. $target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
  21.  
  22. if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
  23. echo "The file ". basename( $_FILES['uploadedfile']['name']).
  24. " has been uploaded";
  25. } else{
  26. echo "There was an error uploading the file, please try again!";
  27. }
  28. ?>
  29.  
  30. </head>
  31. </body>
  32. </html>


z

  1. <?php
  2.  
  3. $site_name = $_SERVER['HTTP_HOST'];
  4. $url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
  5. $url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
  6.  
  7. $upload_dir = "prace";
  8. $upload_url = $url_dir."/prace/";
  9. $message ="";
  10.  
  11. //create upload_files directory if not exist
  12. //If it does not work, create on your own and change permission.
  13. if (!is_dir("prace)) {
  14. die ("upload_files directory doesn't exist");
  15. }
  16.  
  17. if ($_FILES['userfile']) {
  18. $message = do_upload($upload_dir, $upload_url);
  19. }
  20. else {
  21. $message = "Invalid File Specified.";
  22. }
  23.  
  24. print $message;
  25.  
  26. function do_upload($upload_dir, $upload_url) {
  27.  
  28. $temp_name = $_FILES['userfile']['tmp_name'];
  29. $file_name = $_FILES['userfile']['name'];
  30. $file_type = $_FILES['userfile']['type'];
  31. $file_size = $_FILES['userfile']['size'];
  32. $result = $_FILES['userfile']['error'];
  33. $file_url = $upload_url.$file_name;
  34. $file_path = $upload_dir.$file_name;
  35.  
  36. //File Name Check
  37. if ( $file_name =="") {
  38. $message = "Invalid File Name Specified";
  39. return $message;
  40. }
  41. //File Size Check
  42. else if ( $file_size > 500000) {
  43. $message = "The file size is over 500K.";
  44. return $message;
  45. }
  46. //File Type Check
  47. else if ( $file_type == "text/plain" ) {
  48. $message = "Sorry, You cannot upload any script file" ;
  49. return $message;
  50. }
  51.  
  52. $result = move_uploaded_file($temp_name, $file_path);
  53. $message = ($result)?"File url <a href=$file_url>$file_url</a>" :
  54. "Somthing is wrong with uploading a file.";
  55.  
  56. return $message;
  57. }
  58. ?>
  59. <form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">
  60. Upload Image<input type="file" id="userfile" name="userfile">
  61. <input type="submit" name="upload" value="Upload">
  62. </form>


tak zebym nie musial 2 razy wybierac pliku..
Go to the top of the page
+Quote Post

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

 



RSS Aktualny czas: 23.08.2025 - 18:29