Upload img ds pc ok, mais pas en ligne

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Upload img ds pc ok, mais pas en ligne

par Cyrano » 01 sept. 2005, 21:49

[Résolu] :?:

par Invité » 01 sept. 2005, 21:29

Bingo! merci.
C'est pas la 1ère x que ça m'arrive ?!

par rami » 01 sept. 2005, 20:50

Le répertoire où sont uploadées les images est bien accessible en écriture?

par Invité » 01 sept. 2005, 20:05

Voici le code
mysql_select_db($database_db_bastin, $db_bastin);
$query_last_id = "SELECT MAX(id_tourisme) FROM tourisme";
$last_id = mysql_query($query_last_id, $db_bastin) or die(mysql_error());
$row_last_id = mysql_fetch_assoc($last_id);
$totalRows_last_id = mysql_num_rows($last_id);

if(($_POST) && ($_FILES['image']['type'] == "image/jpeg" OR $_FILES['image']['type'] == "image/pjpeg") && $_FILES['image']['error'] == 0) {
$nom_fichier=$row_last_id['MAX(id_tourisme)']."_T.jpg";
$nom_temp = $_FILES['image']['tmp_name'];
$dossier = "../img/up/tourisme/photo/";
move_uploaded_file($nom_temp,$dossier.$nom_fichier);
//recalibration image
$chemin = $dossier.$nom_fichier;
//echo $chemin; exit;
	$max_width = 500;
	$max_height = 420;
	
	$size=getimagesize($chemin);
	$width=$size[0];
	$height=$size[1];
	print_r($size);
	
	$x_ratio=$max_width/$width;
	$y_ratio=$max_height/$height;
	
	if (($width <= $max_width) && ($height <= $max_height))
	{
		$tn_width=$width;
		$tn_height=$height;
	}
	else if (($x_ratio * $height) < $max_height)
	{
		$tn_height = ceil($x_ratio * $height);
		$tn_width = $max_width;
	}
	else {
		$tn_width = ceil($y_ratio * $width);
		$tn_height = $max_height;
	}
	
	$src = imagecreatefromjpeg($chemin);
	$dst = imagecreatetruecolor($tn_width,$tn_height);
	//imagecreatetruecolor
	imagecopyresized($dst,$src,0,0,0,0,$tn_width,$tn_height,$width,$height);
	//header("content-type: image/jpeg");
	$couleurrouge = imagecolorallocate($dst, 125, 125, 125);
	imagestring($dst, 2, 2, 2, "", $couleurrouge);
	
	//imagejpeg($dst, "up/photo/minimenu.jpg", -1); //écrit l'image réduite sur le serveur
	imagejpeg($dst, $chemin, 80); //renvoie l'image au navigateur
	imagedestroy($src);
	imagedestroy($dst);
	
//fin recalibration image
//création vignette

//echo $chemin; exit;
	$max_width = 85;
	$max_height = 85;
	
	$size=getimagesize($chemin);
	$width=$size[0];
	$height=$size[1];
	
	$x_ratio=$max_width/$width;
	$y_ratio=$max_height/$height;
	
	if (($width <= $max_width) && ($height <= $max_height))
	{
		$tn_width=$width;
		$tn_height=$height;
	}
	else if (($x_ratio * $height) < $max_height)
	{
		$tn_height = ceil($x_ratio * $height);
		$tn_width = $max_width;
	}
	else {
		$tn_width = ceil($y_ratio * $width);
		$tn_height = $max_height;
	}
	
	$src = imagecreatefromjpeg($chemin);
	$dst = imagecreatetruecolor($tn_width,$tn_height);
	//imagecreatetruecolor
	imagecopyresized($dst,$src,0,0,0,0,$tn_width,$tn_height,$width,$height);
	//header("content-type: image/jpeg");
	$couleurrouge = imagecolorallocate($dst, 125, 125, 125);
	
	//imagestring($dst, 2, 2, 2, "MON NOM COPYRIGHT", $couleurrouge); //AJOUT COPYRIGHT__
	
	//imagejpeg($dst, "up/vignette/minimenu.jpg", -1); //écrit l'image réduite sur le serveur
	$dossier="../img/up/tourisme/vignette/";
	$chemin = $dossier.$nom_fichier;
	imagejpeg($dst, $chemin, 80); //renvoie l'image au navigateur
	imagedestroy($src);
	imagedestroy($dst);
//fin création vignette


par iclo » 01 sept. 2005, 18:17

Sans voir le code; on ne peut pas t'aider :wink: :wink:

Upload img ds pc ok, mais pas en ligne

par pixfacto » 01 sept. 2005, 18:16

Bonjour,

Quand je teste l'upload d'images en local, ds mon pc, ton fonctionne nickel.
Quand je le teste sur le net, les données et le nom de l'image sont insérées ds la db, mais l'image en tant que telle n'arrive pas ds le dossier "img/up".

Or les chemins sont corrects.

D'où vient le prob? du serveur distant?

Merci
Pierre