Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Walidacja zdjęć + formularz
#6
to pomoże
Kod PHP:
/** loop through the array of files ***/
        
for($i=0$i count($_FILES['userfile']['tmp_name']);$i++)
        {
if(!empty(
$_FILES['userfile']['name'][$i])) {        
if((
$_FILES['userfile']['type'][$i] == "image/jpg") || ($_FILES['userfile']['type'][$i] == "image/jpeg") || ($_FILES['userfile']['type'][$i] == "image/png") || ($_FILES['userfile']['type'][$i] == "image/gif") || ($_FILES['userfile']['type'][$i] == "image/pjpeg")) {
            
            
// check if there is a file in the array
            
if(!is_uploaded_file($_FILES['userfile']['tmp_name'][$i]))
            {
              
$messages[] = 'No file uploaded @';
            }
            
// check the file is less than the maximum file size
            
elseif($_FILES['userfile']['size'][$i] > $max_file_size)
            {
              
$messages[] = "File size exceeds $max_file_size limit";
            }
            else
            {   
              
              
// copy the file to the specified dir 
              
if(move_uploaded_file($_FILES['userfile']['tmp_name'][$i],$_SERVER['DOCUMENT_ROOT'].$upload_dir.$_FILES['userfile']['name'][$i]))
              {
                
/*** give praise and thanks to the php gods ***/
                
$messages[] = $_FILES['userfile']['name'][$i].' uploaded';
              }
              else
              {
                
/*** an error message ***/
                
$messages[] = 'Uploading '.$_FILES['userfile']['name'][$i].' Failed';
              }
            }
        }
}
        } 
Odpowiedz


Wiadomości w tym wątku
Walidacja zdjęć + formularz - przez harvester2001 - 21-03-2014, 22:33
RE: Walidacja zdjęć + formularz - przez Engine - 22-03-2014, 14:45
RE: Walidacja zdjęć + formularz - przez Engine - 22-03-2014, 17:46
RE: Walidacja zdjęć + formularz - przez Engine - 23-03-2014, 01:16

Podobne wątki…
Wątek: Autor Odpowiedzi: Wyświetleń: Ostatni post
  Jak zrobic Formularz Kontaktowy na stronie ? Kodarth 191 255,845 06-04-2021, 16:25
Ostatni post: zerin
  Weryfikacja zdjęć na stronie widzaceoko 0 1,708 19-02-2018, 02:26
Ostatni post: widzaceoko
  Jak zrobić prostą przeglądarkę zdjęć? messi19125 3 4,308 21-07-2014, 02:41
Ostatni post: Kartofelek
  php formularz - wszystkie pola muszą być wypełnione d3d3d3 2 3,636 01-10-2013, 14:16
Ostatni post: Kartofelek
  [PHP] Formularz mailowy - wysyłanie wiadomości spolprog 7 6,496 05-09-2013, 17:13
Ostatni post: Engine

Skocz do:


Użytkownicy przeglądający ten wątek: 2 gości
Sponsorzy i przyjaciele
SeoHost.pl