Page 1 sur 1

soucis avec un script upload

Posté : 15 oct. 2013, 20:15
par pacphil
bonjour voilà j'essaye de comprendre et de mettre en place un petit site que je trouve sympa, j'ai résolut beaucoup des erreurs mais je peine sur cette partie.
<?php
error_reporting(E_ALL ^ E_NOTICE);

/// A definir dans l'url d'appel : url complete de l'image ainsi que $w_max et $h_max

$taille = getimagesize("$pic"); 
$h_i = $taille[1]; 
$w_i = $taille[0]; 
	if($h_i >$h_max) 
	{ 
	$convert=$h_max/$h_i; 
	$h_i=$h_max; 
	$w_i=ceil($w_i*$convert); 
	} 
	if($w_i >$w_max) 
	{ 
	$convert=$w_max/$w_i; 
	$w_i=$w_max; 
	$h_i=ceil($h_i*$convert); 
	} ; 

$largeur = "$w_i";
$hauteur ="$h_i";

header("Content-Type: image/jpeg");
list($width, $height, $type, $attr) = getimagesize("$pic");

if($type == "1")
{
$img_in = imagecreatefromgif($pic);
}
if($type == "2")
{
$img_in = imagecreatefromjpeg($pic);
}
if($type == "3")
{
$img_in = imagecreatefrompng($pic);
}
$img_out = imagecreatetruecolor($largeur, $hauteur);
imagecopyresampled($img_out, $img_in, 0, 0, 0, 0, imagesx($img_out), imagesy($img_out), imagesx($img_in), imagesy($img_in));
$t = imagejpeg($img_out);
echo $t;

?>
<?php
$repdossier = $_GET['repdossier'];
?>
<!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" dir="ltr">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<title>AJAX File Upload - Web Developer Plus Demos</title>
<script type="text/javascript" src="js/jquery-1.3.2.js" ></script>
<script type="text/javascript" src="js/ajaxupload.3.5.js" ></script>
<link rel="stylesheet" type="text/css" href="./styles.css" />
<script type="text/javascript" >
	$(function(){
	var btnUpload=$('#upload');
		var status=$('#status');
		new AjaxUpload(btnUpload, {
<?php
echo "action: 'upload-file.php?repdossier=".$repdossier."',";
?>

			name: 'uploadfile',
			onSubmit: function(file, ext){
				 if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){ 
                    // extension is not allowed 
					status.text('Les extentions possible sont JPG, PNG ou GIF');
					return false;
				}
				status.html('Envoi en cours <img src="images/loadingup.gif?<?php echo md5(time()); ?>" border="0" height="6" width="19">');
			},
			onComplete: function(file, response){
				//On completion clear the status
				status.text('');
				//Add uploaded file to list
				if(response==="success"){
					$('<li></li>').appendTo('#files').html('<img src="miniature.php?pic=upload/<?php echo $repdossier; ?>/'+file+'&w_max=70&h_max=60" height="60" width="70" alt="" /><br />').addClass('success');
				} 
                                 if(response==="error1"){
					alert("Vous avez déjà 5 photos pour votre annonce !\nLe maximum de photos autorisées est de 5 !")
				} 
                                if(response==="error2"){
				        alert("La photo selectionnée existe déjà\nRe-selectionnez une autre photo !")
				} 
			}
		});
		
	});
</script>
</head>
<body>

<div id="mainbody" >
<div id="upload" ><b>Ajouter des photos</b></div><span id="status" ></span>

		 <ul id="files" ></ul>
</div>
</body>
</html>

Re: soucis avec un script upload

Posté : 15 oct. 2013, 20:33
par moogli
salut,

peux être que si tu explique ton problème quelqu'un pourra t'aider :mrgreen:


@+