1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
   |  
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple PHP Form Demo</title>
</head>
	<body>
 
		<form id="contact_form" method="post" action=".">
 
 
			<?php           
 
			//	echo "Fichier à écrire : ".$cible;
 
				$fichier="C:\\Users\\Public\\Pictures\\Sample Pictures\\Koala.jpg"
 
				if ($_FILES['fichier']['error']) {     
					switch ($_FILES['fichier']['error']){     
					   case 1: // UPLOAD_ERR_INI_SIZE     
						   echo"Le fichier dépasse la limite autorisée par le serveur (fichier php.ini) !";     
						   break;     
					   case 2: // UPLOAD_ERR_FORM_SIZE     
						   echo "Le fichier dépasse la limite autorisée dans le formulaire HTML !"; 
						   break;     
					   case 3: // UPLOAD_ERR_PARTIAL     
						   echo "L'envoi du fichier a été interrompu pendant le transfert !";     
						   break;     
					   case 4: // UPLOAD_ERR_NO_FILE     
						   echo "Le fichier que vous avez envoyé a une taille nulle !"; 
						   break;     
					  }     
				}     
				else {     
					 // $_FILES['nom_du_fichier']['error'] vaut 0 soit UPLOAD_ERR_OK     
					 // ce qui signifie qu'il n'y a eu aucune erreur   
					 $cible="c:\\tmp\\test.jpg";
					print  $_FILES['fichier']['name']."</br>";
					print  $_FILES['fichier']['size']."</br>";
					print  $_FILES['fichier']['type']."</br>";
					print  $_FILES['fichier']['tmp_name']."</br>";
 
					$source=$_FILES['fichier']['tmp_name'];
					if (!copy($source, $cible)) {
						echo "ERREUR : La copie du fichier ".$cible." a échoué...\n";
					}
 
 
					 copy($_FILES['fichier']['tmp_name'],$cible);
					 echo "La copie du fichier ".$cible." a réussi...\n";
 
 
				}     
			?>
		</form>
 
	</body>
</html> | 
Partager