par
testlor » 02 sept. 2008, 11:32
$idannonce = $_POST['numero'];
$path = "../upload/galeriephoto/";
chmod($path,0777);
// upload image
if (is_uploaded_file($_FILES['Filedata']['tmp_name'])) {
$source_file = $path.$idannonce.(strtolower($_FILES['Filedata']['name']));
move_uploaded_file($_FILES['Filedata']['tmp_name'], $source_file);
function createthumb($name,$filename,$new_w,$new_h){
$name=strtolower($name);
$system=explode(".",$name);
if(preg_match("/jpg|jpeg/",$system[1])){
$src_img=imagecreatefromjpeg("../upload/galeriephoto/".$idannonce.$name);
}
if(preg_match("/png/",$system[1])){
$src_img=imagecreatefrompng("../upload/galeriephoto/".$idannonce.$name);
}
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
if (preg_match("/png/",$system[1])){
imagepng($dst_img,"../upload/galeriephoto/miniatures/".mktime().$filename);
}else{
imagejpeg($dst_img,"../upload/galeriephoto/miniatures/".mktime().strtolower($filename));
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
createthumb($_FILES["Filedata"]["name"],"mini_".$_FILES["Filedata"]["name"],150,150);
}
?>
il n'y a pas de redirection dans la page upload comme tu peu le voir ci dessus.
Je suis de ton avis que la redirection se fait grâce au javascript.
Car l'interêt de rester sur la page d'upload c'est qu'il y a une barre de chargement jusqu'à 100% pour chaque image ( un peu de dynamisme^^ ) donc il faut rester sur cette page.
Je conçois que le javascript ( langage que je ne maitrise pas ) fasse cette redirection
Mais il me semble qu'il ne devrait en aucun poser de problème quand a la transmission de mon champ hidden
[php]
$idannonce = $_POST['numero'];
$path = "../upload/galeriephoto/";
chmod($path,0777);
// upload image
if (is_uploaded_file($_FILES['Filedata']['tmp_name'])) {
$source_file = $path.$idannonce.(strtolower($_FILES['Filedata']['name']));
move_uploaded_file($_FILES['Filedata']['tmp_name'], $source_file);
function createthumb($name,$filename,$new_w,$new_h){
$name=strtolower($name);
$system=explode(".",$name);
if(preg_match("/jpg|jpeg/",$system[1])){
$src_img=imagecreatefromjpeg("../upload/galeriephoto/".$idannonce.$name);
}
if(preg_match("/png/",$system[1])){
$src_img=imagecreatefrompng("../upload/galeriephoto/".$idannonce.$name);
}
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
if (preg_match("/png/",$system[1])){
imagepng($dst_img,"../upload/galeriephoto/miniatures/".mktime().$filename);
}else{
imagejpeg($dst_img,"../upload/galeriephoto/miniatures/".mktime().strtolower($filename));
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
createthumb($_FILES["Filedata"]["name"],"mini_".$_FILES["Filedata"]["name"],150,150);
}
?>
[/php]
il n'y a pas de redirection dans la page upload comme tu peu le voir ci dessus.
Je suis de ton avis que la redirection se fait grâce au javascript.
Car l'interêt de rester sur la page d'upload c'est qu'il y a une barre de chargement jusqu'à 100% pour chaque image ( un peu de dynamisme^^ ) donc il faut rester sur cette page.
Je conçois que le javascript ( langage que je ne maitrise pas ) fasse cette redirection
Mais il me semble qu'il ne devrait en aucun poser de problème quand a la transmission de mon champ hidden