Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
manuweb2  
#1 Posted : Sunday, April 15, 2007 9:50:10 PM(UTC)
manuweb2

Rank: Member

Groups: Member
Joined: 4/15/2007(UTC)
Posts: 2

Hi everyone,
i have image uploader java version and he is working well in localhost.

Since image uploader is on my website is still workig well, but the $filecount = $_POST["FileCount"]; is not working, is still $filecount = 0 ...
(so the files are not copied in my directory, and the values not inserted in my dbb)
i have tried many things, read all the topics, but my problem is still here.

here my code :

Code:
<?php

//This variable specifies relative path to the folder, where the gallery with uploaded files is located.
//Do not forget about the slash in the end of the folder name.
$galleryPath = "../books/";

$absGalleryPath = realpath($galleryPath);

include("connex.php");
mysql_connect($host,$user,$pass) or die("Impossible de se connecter");
mysql_select_db($bdd) or die("Impossible de se connecter");
		
function mini($img_src,$img_dest) {
   // Lit les dimensions de l'image
   $size = GetImageSize($img_src);  
   $src_w = $size[0]; $src_h = $size[1];  
      // Copie dedans l'image initiale redimensionnée
      $src_im = ImageCreateFromJpeg($img_src);
	  
	   if($src_w>=$src_h){
	   	  // Crée une image vierge aux bonnes dimensions
      	$dst_im = ImageCreateTrueColor(125,125);
		$inf = $src_h/125;
		$inf = $src_w/$inf;
		imagecopyresampled($dst_im,$src_im,0,0,0,0,$inf,125,$src_w,$src_h);
	   }   
	   elseif($src_h>$src_w){
	   	  // Crée une image vierge aux bonnes dimensions
     	 $dst_im = ImageCreateTrueColor(125,125);
		 $inf = $src_w/125;
		 $inf = $src_h/$inf;
		  imagecopyresampled($dst_im,$src_im,0,0,0,0,125,$inf,$src_w,$src_h);
	   }
      // Sauve la nouvelle image
      ImageJpeg($dst_im,$img_dest);
      // Détruis les tampons
      ImageDestroy($dst_im);  
      ImageDestroy($src_im);
}

function saveUploadedFiles()
{
	global $absGalleryPath;
		
	//Create XML file which will keep information about files (image dimensions, description, etc). 
	//XML is used solely for brevity. In real-life application most likely you will use database instead.
	$descriptions = new DOMDocument('1.0');
	$descriptions->appendChild($descriptions->createElement("files"));
	
	//Get total number of uploaded files (all files are uploaded in a single package).
[color=#FF0000]	$fileCount = $_POST["FileCount"];
	//HERE IS THE PROBLEM[/color]
	//Iterate through uploaded data and save the original file, thumbnail, and description.
	for ($i = 1; $i <= $fileCount; $i++)
	{	
		//on ajoute dans la base de données :
		$id = $_GET['id'];
		$verif = mysql_query("Select id from pics where nid='$id'"); 
		$nb = mysql_num_rows($verif);
		$ordre = $nb + 1; //on recup le numero d'ordre
		$query = "INSERT INTO pics(nid) VALUES('$id')"; 
		$result = mysql_query($query); 
		$last_id = mysql_insert_id();
		//Get the first thumbnail and save it to disk. It stores 1200x1200 optimized image.
		$thumbnail1Field = "Thumbnail1_" . $i;
		if (!$_FILES[$thumbnail1Field]['size'])
		{
			return;	
		}
		$fileName = $id."_".$last_id.".jpg";	
		$fileName_mini = $id."_".$last_id."_mini2.jpg";
		//a modifier : 	ajouté nom désiré
		move_uploaded_file($_FILES[$thumbnail1Field]['tmp_name'], $absGalleryPath . "/" . $fileName);
		$fichier = $absGalleryPath . "/" . $fileName;
		$fichier_mini = $absGalleryPath . "/" . $fileName_mini;
		$picture = $fileName;
		$picture_min2 = $fileName_mini;
		
		$fileName = $id."_".$last_id."_mini.jpg";	
		//Get the second thumbnail and save it to disk. It stores 120x120 preview image. 
		$thumbnail2Field = "Thumbnail2_" . $i;
		if (!$_FILES[$thumbnail2Field]['size'])
		{
			return;	
		}
		move_uploaded_file($_FILES[$thumbnail2Field]['tmp_name'], $absGalleryPath . "/" . $fileName);
		$fichiers_mini = $absGalleryPath . "/" . $fileName;
		$picture_min = $fileName;
		
		//Ajout du logo EGO sur petite image
		$dimension=getimagesize($fichiers_mini);
		$chemin = imagecreatefromjpeg($fichiers_mini); 
		$copy = imagecreatefromgif('../img/copyright2.gif');
		$larg_cop=imagesx($copy);
		$long_cop=imagesy($copy); 
		//calcul la position du copyright sur l'axe des abscisses
		$x=(($dimension[0]/2)-($larg_cop/2));
		//calcul la position du copyright sur l'axe des ordonn&eacute;es
		$y=($dimension[1]-$long_cop-4/2);
		//r&eacute;alisation de la superposition
		imagecopymerge($chemin,$copy, $x, $y, 0, 0, $larg_cop, $long_cop, 40);
		imagejpeg($chemin,$fichiers_mini);
		// fin ajout logo


		$fileName = $id."_".$last_id."_acc.jpg";
		$thumbnail3Field = "Thumbnail3_" . $i;
		if (!$_FILES[$thumbnail3Field]['size'])
		{
			return;	
		}
		move_uploaded_file($_FILES[$thumbnail3Field]['tmp_name'], $absGalleryPath . "/" . $fileName);
		$picture_acc = $fileName;
		
		//creation sous PHP de la mini aux dimensions carrés
		mini($fichier,$fichier_mini);
		
		//Ajout du logo EGO sur grande image
		$dimension=getimagesize($fichier);
		$chemin = imagecreatefromjpeg($fichier); 
		$copy = imagecreatefromgif('../img/copyright.gif');
		$larg_cop=imagesx($copy);
		$long_cop=imagesy($copy); 
		//calcul la position du copyright sur l'axe des abscisses
		$x=($dimension[0]-$larg_cop);
		//calcul la position du copyright sur l'axe des ordonn&eacute;es
		$y=($dimension[1]-$long_cop-10);
		//r&eacute;alisation de la superposition
		imagecopymerge($chemin,$copy, $x, $y, 0, 0, $larg_cop, $long_cop, 40);
		imagecopymerge($chemin,$copy, 0, 10, 0, 0, $larg_cop, $long_cop, 40);
		imagejpeg($chemin,$fichier);
		// fin ajout logo
		
		$maj = "UPDATE pics SET picture='$picture', picture_acc='$picture_acc', picture_min='$picture_min', picture_min2='$picture_min2', ordre='$ordre' WHERE id='$last_id'"; 
		$maj2 = mysql_query($maj);
	}
	mysql_close(); 
}

saveUploadedFiles();
?>



If someone already know how to fix the problem, would you mind help me.

I hope i've well explained my problemn and sorry for my english ;)

Edited by user Tuesday, December 18, 2007 4:04:26 AM(UTC)  | Reason: Not specified

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.