Follow along with the video below to see how to install our site as a web app on your home screen.
Бележка: This feature may not be available in some browsers.
<html>
<head>
<title>Формуляр за качване</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data">
<p>
Файл:
<input type="file" name="file" size="40">
<br>
Ново име:
<input type="text" name="name" size="50">
<input type="submit" value="Качване">
</p>
</form>
</body></html>
<?php
if ($_FILES['file']['name'] !=""){
copy($_FILES['file']['tmp_name'], $_POST['name']) or die ("Файлът не може да бъде качен!");
}else{
die( "Няма избран файл!");
}
#Проверява дали има избран файл и дали може да бъде копиран.
#Синтаксис на функцията copy() : copy("файл","ново име на файла")
#В нашият слуай това е текущото име на файла и въведеното в формата ново име
?>
<html>
<head>
<title>Формуляр за качване</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
</head>
<body>
<?php
$name = $_FILES['file']['name']; //Името
$size = $_FILES['file']['size']; //Големината (в байтове)
$type = $_FILES['file']['type']; //Вида на файла
?>
<a href="<?php echo ("$name"); ?>">Файлът</a> с размер <b><?php echo ("$size"); ?></b> байта от тип <b><?php echo ("$type"); ?></b> е качен успешно!
</body>
</html>
<?php
$target = 'upload/'; // Repertoire cible
$extension = 'flv'; // Extension du fichier sans le .
$max_size = 100000; // Taille max en octets du fichier
$width_max = 100; // Largeur max de l'image en pixels
$height_max = 100; // Hauteur max de l'image en pixels
$nom_file = $_FILES['fichier']['name'];
$taille = $_FILES['fichier']['size'];
$tmp = $_FILES['fichier']['tmp_name'];
?>
<html>
<head>
<title>Upload d'une image sur le serveur !</title>
</head>
<body>
<?php
if(!empty($_POST['posted'])) {
// On ve'rifie si le champ est rempli
if(!empty($_FILES['fichier']['name'])) {
// On ve'rifie l'extension du fichier
if(substr($nom_file, -3) == $extension) {
// On re'cupe`re les dimensions du fichier
$infos_img = getimagesize($_FILES['fichier']['tmp_name']);
// On ve'rifie les dimensions et taille de l'image
if((($_FILES['fichier']['size'] <= $max_size)) {
// Si c'est OK, on teste l'upload
if(move_uploaded_file($_FILES['fichier']['tmp_name'],$target.$_FILES['fichier']['name'])) {
// Si upload OK alors on affiche le message de re'ussite
echo '<b>Image uploade'e avec succe`s !</b>';
echo '<hr />';
echo '<b>Fichier :</b> ', $_FILES['fichier']['name'], '<br />';
echo '<b>Taille :</b> ', $_FILES['fichier']['size'], ' Octets<br />';
echo '<b>Largeur :</b> ', $infos_img[0], ' px<br />';
echo '<b>Hauteur :</b> ', $infos_img[1], ' px<br />';
echo '<hr />';
echo '<br /><br />';
} else {
// Sinon on affiche une erreur syste`me
echo '<b>Proble`me lors de l\'upload !</b><br /><br /><b>', $_FILES['fichier']['error'], '</b><br /><br />';
}
} else {
// Sinon on affiche une erreur pour les dimensions et taille de l'image
echo '<b>Proble`me dans les dimensions ou taille de l\'image !</b><br /><br />';
}
} else {
// Sinon on affiche une erreur pour l'extension
echo '<b>Votre image ne comporte pas l\'extension .jpg !</b><br /><br />';
}
} else {
// Sinon on affiche une erreur pour le champ vide
echo '<b>Le champ du formulaire est vide !</b><br /><br />';
}
}
?> <form enctype="multipart/form-data" action="<?php echo $PHP_SELF; ?>" method="POST">
<b>Envoyer le fichier :</b><br /><br />
<input type="hidden" name="posted" value="1" />
<input name="fichier" type="file" />
<input type="submit" value="Uploader" />
</form>
</body>
</html>