Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> jeden użytkownik jeden plik
vojtek_
post
Post #1





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 13.03.2005

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


Jak zrobic zeby na uploadzie jeden zarejestrowany uzytkownik mial jeden plik (jeden obrazek (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) ) np: users_obrazek.gif i jak wysle drugi
to ten pierwszy sie podmieni (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
vojtek_
post
Post #2





Grupa: Zarejestrowani
Postów: 32
Pomógł: 0
Dołączył: 13.03.2005

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


To jest forum txtBB.
Mozna go sciagnac z oficjalnej strony forum. A mój upload daje tu:

  1. <?php
  2.  
  3. $site_name = $_SERVER['HTTP_HOST'];
  4. $url_dir = &#092;"http://\".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
  5. $url_this =  &#092;"http://\".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
  6.  
  7. $upload_dir = &#092;"upload_files/\";
  8. $upload_url = $url_dir.&#092;"/upload_files/\";
  9. $message =&#092;"\";
  10.  
  11. if (!is_dir(&#092;"upload_files\")) {
  12.         die (&#092;"Nie ma folderu do przechowywania pliku.\");
  13. }
  14.  
  15. if ($_FILES['userfile']) {
  16.         $message = do_upload($upload_dir, $upload_url);
  17. }
  18. else {
  19.         $message = &#092;"Nie załadowano pliku.\";
  20. }
  21.  
  22. print $message;
  23.  
  24. function do_upload($upload_dir, $upload_url) {
  25.  
  26.         $temp_name = $_FILES['userfile']['tmp_name'];
  27.         $file_name = $_FILES['userfile']['name']; 
  28.         $file_type = $_FILES['userfile']['image/gif']; 
  29.         $file_size = $_FILES['userfile']['size']; 
  30.         $result    = $_FILES['userfile']['error'];
  31.         $file_url  = $upload_url.$file_name;
  32.         $file_path = $upload_dir.$file_name;
  33.         $im=getimagesize($temp_name);
  34. if (($im[2]!=1) && ($im[2]!=2))  {
  35.   $message=&#092;"Niewłaściwy typ pliku\";
  36.   return($message);
  37. }
  38.  
  39. else if ($file_name==&#092;"\")
  40.  
  41.         //File Name Check
  42.     if ( $file_name ==&#092;"txtbb2\") { 
  43.             $message = &#092;"Nie załadowano pliku\";
  44.             return $message;
  45.     }
  46.     //Wielkość pliku
  47.     else if ( $file_size > 500000) {
  48.         $message = &#092;"The file size is over 500K.\";
  49.         return $message;
  50.     }
  51.     //File Type Check
  52.     else if ( $file_type == &#092;"text/plain\" ) {
  53.         $message = &#092;"Niewłaściwy typ pliku\" ;
  54.         return $message;
  55.     }
  56.  
  57.     $result  =  move_uploaded_file($temp_name, $file_path);
  58.     $message = ($result)?&#092;"Adres pliku <a href=$file_url>$file_url</a>\" :
  59.                   &#092;"Ten adres nie istnieje..\";
  60.  
  61.     return $message;
  62. }
  63. ?>
  64.  
  65.  
  66. <form name=\"upload\" id=\"upload\" ENCTYPE=\"multipart/form-data\" method=\"post\">
  67.  <small>Wybierz obraz</small>  
  68.   <input type=\"file\" id=\"userfile\" name=\"userfile\">
  69.   <input type=\"submit\" name=\"Ładuj\" value=\"Ładuj\">
  70. </form>  

Ja jeszcze to includuje na inna strone (IMG:http://forum.php.pl/style_emoticons/default/snitch.gif)

Ten post edytował vojtek_ 17.03.2005, 12:49:42
Go to the top of the page
+Quote Post

Posty w temacie


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: 26.12.2025 - 09:59