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
| if(isset($_FILES['photo'])and $_FILES['photo']['error']==0)
{
if($_FILES['photo']['size']<=1000000)
{
$extension=pathinfo($_FILES['photo']['name']);
$extension_recuperer=strtolower($extension['extension']);
$extension_autorisees=array('jpg','jpeg','png','gif');
if(in_array($extension_recuperer,$extension_autorisees))
{
$aide=move_uploaded_file($_FILES['photo']['tmp_name'],'Mesphotos/' .basename($_FILES['photo']['name']));
if($aide){
$chemin='Mesphotos/'.$_POST['code'].basename($_FILES['photo']['name']);
echo $chemin;
$ajout=$connexion_a_la_db->prepare('insert into Image(url,codeProduit)
values(:url,:codeProduit)');
$ajout->execute(
array(
':url'=>$chemin,
':codeProduit'=>$_POST['code']
)
);
}
}
}
} |
Partager