for($i=1;$i<=9;$i++){ if(isset($_POST['photo'.$i])){ echo "<br>".$_POST['photo'.$i]." => ".UploadFile('../images/',$_POST['photo'.$i]); } } function UploadFile($rep,$file){ $obj = new upload($rep, $file); // on déclare les variables qu'on a besoin $obj->cl_taille_maxi = 49000000; // pour 49 Mo maximum $obj->cl_extensions = array('.gif','.jpg','.png'); // les extensions autorisées // on envoi le fichier if (!$obj->uploadFichier()){ // affichage d'une erreur en cas d'echec $msg = $obj->affichageErreur(); }else{ $msg="ok"; } return $msg; }
<input name="xyz[]" value="Lorem" /> <input name="xyz[]" value="ipsum" /> <input name="xyz[]" value="dolor" /> <input name="xyz[]" value="sit" /> <input name="xyz[]" value="amet" />
<div class="up"> <label for="photo3">Photo 2</label> <input type="file" name="photo[]" /> </div> <div class="up"> <label for="photo3">Photo 3</label> <input type="file" name="photo[]" /> </div>
Echo $_POST['xyz'][0] ; // ==>va afficher 'Lorem' Echo $_POST['xyz'][4]; // ==> va afficher 'amet'
$pic2=$nomdestination; $explode= explode(".",$pic2); $photo2=$explode[0]; $ext2=$explode[1];
<form name="monformulaire" methode="POST" action="mapage.php"> <input type="text" id="input1" name="toto[]" value="" > <input type="text" id="input2" name="toto[]" value="" > <input type="submit" value="Valider"> </form>
<form action="traitement?ref=<?php echo $id;?>" method="POST" enctype="multipart/form-data">
<div class="element">
<label for="photo2">Photo 2 <span class="red"> *</span></label>
<input type="file" name="photo[]" />
</div>
<div class="element">
<label for="photo3">Photo 3</label>
<input type="file" name="photo[]" />
</div>
for($i=1;$i<=9;$i++)
{
if(isset($_POST['photo'.$i]))
{
echo "<br>".$_POST['photo'.$i]." => ".UploadFile('../uploads/',$_POST['photo'.$i]);
}
}
$pic=$_POST['photo1'];
$explode= explode(".",$pic);
$photo1=$explode[0];
$ext1=$explode[1];
$rq='INSERT into portfolio(id_lien,photo,ext)
values ("'.$id_bien.'","'.$photo1.'","'.$ext1.'")';
$result=mysql_query($rq);
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question$photos = $_POST['photo']; foreach ( $photos as $photo ){ echo "<br>".$photo." -> "; Echo UploadFile('../uploads/',$photo); // ici tu traites aussi tes explodes...et ton insertion en BDD }
$photos = $_POST['photo'];
foreach ( $photos as $photo )
{
echo "<br>".$photo." -> ";
echo UploadFile('../uploads/',$photo);
$explode= explode(".",$photo);
$photo1=$explode[0];
$ext1=$explode[1];
$rq='INSERT into porfolio(id_lien,photo,ext)
values ("'.$id_bien.'","'.$photo1.'","'.$ext1.'")';
$result=mysql_query($rq);
}
if (isset($_POST['photo'])){ $photos = $_POST['photo']; foreach ( $photos as $photo ){ Echo "<br>".$photo." -> "; Echo UploadFile('../uploads/',$photo); // ici tu traites aussi tes explodes...et ton insertion en BDD } }else{ Echo " <br><b> AUCUNE PHOTO N'A ETE PASSEE EN ARGUMENT ! </b><br>"; }
<form action="traitement_portfolio.php?ref=<?php echo $id;?>" method="POST" enctype="multipart/form-data">
<div class="up">
<label for="photo2">Photo 2 </label>
<input type="file" name="photo[]" />
</div>
<div class="up">
<label for="photo3">Photo 3 </label>
<input type="file" name="photo[]" />
</div>
<div class="up">
<label for="photo4">Photo 4 </label>
<input type="file" name="photo[]" />
</div>
<div class="up">
<label for="photo5">Photo 5 </label>
<input type="file" name="photo[]" />
</div>
<div class="up">
<label for="photo6">Photo 6</label>
<input type="file" name="photo[]" />
</div>
<div class="up">
<label for="photo7">Photo 7 </label>
<input type="file" name="photo[]" />
</div>
<div class="up">
<label for="photo8">Photo 8 </label>
<input type="file" name="photo[]" />
</div>
<div class="up">
<label for="photo9">Photo 9 </label>
<input type="file" name="photo[]" />
</div>
<div class="up">
<label for="photo10">Photo 10 </label>
<input type="file" name="photo[]" />
</div>
<div class="entry">
<button type="submit" name="soumettre" class="add">VALIDER</button>
<button type="reset" class="cancel">EFFACER</button>
</div>
</form>
print_r($_POST)dans ton fichier traitement_portfolio.php et nous dire ce que ça donne ?
foreach($_FILES as $file => $details) { // Move each file from its temp directory to $ROOT $temp = $details['tmp_name']; $target = $details['name']; Echo "<br>".$target." -> "; Echo UploadFile('../uploads/',$target); }