Bonjour, j'ai un script pho qui redimentione une image puis déclanche son téléchargement:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <?php
if(isset($_FILES['photo']))
{
$dossier = 'imgs/';
$fichier = basename($_FILES['photo']['name']);
if(move_uploaded_file($_FILES['photo']['tmp_name'], $dossier . $fichier)) //Si la fonction renvoie TRUE, c'est que ça a fonctionné...
{
echo 'Upload effectué avec succès !<br>';
exec("mogrify -resize 640x640 imgs/".$fichier);
echo ("<meta http-equiv='Refresh' content='2;URL=telecharg.php?jpg=imgs/$fichier'>");
}
else //Sinon (la fonction renvoie FALSE).
{
echo 'Echec de l\'upload !';
echo ("<meta http-equiv='Refresh' content='2;URL=index.php'>");
}
}
?> |
C'est cette ligne qui lance le téléchargement:
echo ("<meta http-equiv='Refresh' content='2;URL=telecharg.php?jpg=imgs/$fichier'>");
En passant au script suivant:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| <?PHP
if(!isset($_GET['jpg']))
{
header('location:erreur.php');
}
else
{
$file = $_GET['jpg'];
}
header("Content-Type: image/jpeg");
header("Content-Disposition: attachment; filename=".$file);
?> |
Le téléchargement ce déclanche bien, il m'enregistre un fichier portant le nom est l'extenssion de l'image, mais aucun apercu n'est disponibkle pour l'image, donc elle est corompu, voyer vous ce qui cloche dans mon code ,
Partager