Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Co myslicie o takim zabezpieczeniu, przed nadpisaniem pliku
wozniak
post
Post #1





Grupa: Zarejestrowani
Postów: 278
Pomógł: 0
Dołączył: 21.11.2003

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


Jak w temacie o to kod:
  1. <form method=\"post\" enctype=\"multipart/form-data\" action=\"zdjecie.php?x=1\">
  2. <input type=\"file\" name=\"foto\" size=\"20\">
  3. <input type=\"submit\" value=\"Wy&para;lij\" name=\"B1\">
  4. </form>
  5. <?php  
  6.  
  7. if($x == 1 ){
  8.  $nazwa= date(&#092;"y-\");
  9.  $nazwa.= date(&#092;"m\");
  10.  $nazwa.= date(&#092;"d\");
  11. $nazwa1= date(&#092;"H\");
  12. $nazwa1.= date(&#092;"i\");
  13. $nazwa1.= date(&#092;"s\");
  14. if(!file_exists(&#092;"foto/$nazwa$nazwa1$foto_name\")){
  15. copy(&#092;"$foto\", \"foto/$nazwa$nazwa1$foto_name\");
  16.  }
  17.  else{
  18.  print(&#092;"blad\");
  19.  }
  20.  print(&#092;"Zdjecie zostalo dodane
  21.  <img src=&#092;"foto/$nazwa$nazwa1$foto_name\">\");
  22.  }
  23. ?>
Go to the top of the page
+Quote Post
crash
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 196
Pomógł: 2
Dołączył: 17.01.2004
Skąd: Sosnowiec

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


Noo... dobre (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif) Ale bardziej podoba mi się sposób tworzenia $nazwa (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Go to the top of the page
+Quote Post
wozniak
post
Post #3





Grupa: Zarejestrowani
Postów: 278
Pomógł: 0
Dołączył: 21.11.2003

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


No to moze tak:D
  1. <form method=\"post\" enctype=\"multipart/form-data\" action=\"zdjecie.php?x=1\">
  2. <input type=\"file\" name=\"foto\" size=\"20\">
  3. <input type=\"submit\" value=\"Wy&para;lij\" name=\"B1\">
  4. </form>
  5. <?php  
  6.  
  7. if($x == 1 ){
  8.  $nazwa= date(&#092;"ymdHis\");
  9.  
  10. if(!file_exists(&#092;"foto/$nazwa$nazwa1$foto_name\")){
  11. copy(&#092;"$foto\", \"foto/$nazwa$nazwa1$foto_name\");
  12.  }
  13.  else{
  14.  print(&#092;"blad\");
  15.  }
  16.  print(&#092;"Zdjecie zostalo dodane
  17.  <img src=&#092;"foto/$nazwa$foto_name\">\");
  18.  }
  19. ?>
Go to the top of the page
+Quote Post
militis
post
Post #4





Grupa: Zarejestrowani
Postów: 57
Pomógł: 0
Dołączył: 17.08.2004
Skąd: Olsztyn

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


  1.               <form method=\"post\" enctype=\"multipart/form-data\" action=\"<?=$_SERVER['PHP_SELF'] ?>\">
  2.               <input type=\"file\" name=\"foto\" size=\"20\">
  3.               <input type=\"submit\" value=\"Wy&para;lij\" name=\"B1\">
  4.               </form>
  5. <?php     
  6.           
  7.       if($_POST){
  8.           $nazwa= time();
  9.  
  10.               if(!file_exists('foto/' . $nazwa) && move_uploaded_file($_FILES['foto']['tmp_name'], 'foto/' . $nazwa)) {
  11.                     echo('Zdjecie zostalo dodane <img src='foto/' . $nazwa . '>');                                                       }
  12.                } else{
  13.                     echo('błąd);
  14.                }
  15.  
  16.       }
  17. ?>            



pisane z glowy, moze byc gdzies blad

Ten post edytował militis 16.05.2005, 15:03:03
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 - 08:55