WRInaute impliqué
bonjour,
je cherche un code php qui permet du transferet un images dans un poste vers un dossier "images" du server !
j'ai trouve un code mais il ne transferer pas l'images
le code est : *************** photo.php ****************
************* pohotOK**********
Merci d'avance
.
je cherche un code php qui permet du transferet un images dans un poste vers un dossier "images" du server !
j'ai trouve un code mais il ne transferer pas l'images
le code est : *************** photo.php ****************
Code:
<?php
// ---------------------------------------------
// Pure PHP Upload version 1.1
// -------------------------------------------
if (phpversion() > "4.0.6") {
$HTTP_POST_FILES = &$_FILES;
}
define("MAX_SIZE",300000);
define("DESTINATION_FOLDER", "./images/");
define("no_error", "photoOK.php");
define("yes_error", "photo_erreur.php");
$_accepted_extensions_ = "gif,jpg,jpeg,png";
if(strlen($_accepted_extensions_) > 0){
$_accepted_extensions_ = @explode(",",$_accepted_extensions_);
} else {
$_accepted_extensions_ = array();
}
/* modify */
if(!empty($HTTP_POST_FILES['fichier'])){
if(is_uploaded_file($HTTP_POST_FILES['fichier']['tmp_name']) && $HTTP_POST_FILES['fichier']['error'] == 0){
$_file_ = $HTTP_POST_FILES['fichier'];
$errStr = "";
$_name_ = $_file_['name'];
$_type_ = $_file_['type'];
$_tmp_name_ = $_file_['tmp_name'];
$_size_ = $_file_['size'];
if($_size_ > MAX_SIZE && MAX_SIZE > 0){
$errStr = "File troppo pesante";
}
$_ext_ = explode(".", $_name_);
$_ext_ = strtolower($_ext_[count($_ext_)-1]);
if(!in_array($_ext_, $_accepted_extensions_) && count($_accepted_extensions_) > 0){
$errStr = "Estensione non valida";
}
if(!is_dir(DESTINATION_FOLDER) && is_writeable(DESTINATION_FOLDER)){
$errStr = "Cartella di destinazione non valida";
}
if(empty($errStr)){
if(@copy($_tmp_name_,DESTINATION_FOLDER . "/" . $_name_)){
header("Location: " . no_error);
} else {
header("Location: " . yes_error);
}
} else {
header("Location: " . yes_error);
}
}
}
?><!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>Charger photo</title>
<style type="text/css">
<!--
.Style1 {
font-size: 10px;
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #FF0000;
}
-->
</style>
</head>
<body>
<form action="photoOK.php" method="post" enctype="multipart/form-data" name="photo" id="photo">
<table width="100%" border="0">
<tr>
<td colspan="3">Veuillez choisir votre photo, cliquez sur 'Charger' puis suivez les instructions.</td>
</tr>
<tr>
<td width="19%">Choisir votre photo</td>
<td width="36%"><label>
<input type="file" name="fichier" id="fichier"/>
</label></td>
<td width="45%"> </td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" name="submit" id="submit" value="Charger" />
</label></td>
<td> </td>
</tr>
<tr>
<td colspan="3"><p class="Style1">Seulement des fichiers aux extensions <strong>gif, jpg, jpeg et png</strong>. Taille maximu : <strong>300000 octets</strong> (3 Mo)</p></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
************* pohotOK**********
Code:
<body>
<table width="100%" border="0">
<tr>
<td width="100%">Votre photo <?php echo $_FILES['fichier']['name'];?> a ete chargee avec success. </td>
</tr>
<tr></tr>
</table>
</body>
Merci d'avance
.