Jump to content


Photo

Couple of simple errors i can't fix


  • Please log in to reply
5 replies to this topic

#1 DarkHavn

DarkHavn
  • Members
  • PipPipPip
  • Advanced Member
  • 69 posts

Posted 01 September 2006 - 04:13 AM

Hey, i posted before about a form upload, have sat down and keyed up some ideas, and read through a few tutorials.

Got everything that i'm trying to do in a nutshell, Take a look at the following code

if($_POST['next']) {


foreach ($_FILES["image"]["error"] as $key => $error) {
$maxfilesize = 734349;
$mimetype = array('image/pjpeg','image/jpeg','image/jpg');
    if($_FILES['image']['size'][$key] >= $maxfilesize){
		$errormsg = 'Remember you can not upload a file larger than 700kb, and only .jpg images are allowed!';
		break;
	
			
	//	move_uploaded_file($tmp_name, "data/$name");
		} else {
		$bname = $_SESSION['clients'];
	//	$tmp_name = $_FILES["image"]["tmp_name"][$key];
      //  $name = $_FILES["image"]["name"][$key];
		//$filesize = $_FILES['image']['size'][$key];
		
		    $size = 150; // the thumbnail height 
       $filedir = "../../Clients/$bname/images/"; // the directory for the original image 
	   chmod($filedir, 777);
      $thumbdir = "../../Clients/$bname/images/";  // the directory for the thumbnail image 
      $prefix = 'small_'; // the prefix to be added to the original name 
      $maxfile = '2000000'; 
      $mode = '0666'; 
       $userfile_name = $_FILES['image']['name'][$key]; 
       echo "$userfile_name";
	   $userfile_tmp = $_FILES['image']['tmp_name'][$key]; 
       $userfile_size = $_FILES['image']['size'][$key]; 
       $userfile_type = $_FILES['image']['type'][$key]; 
       if (isset($_FILES['image']['name'][$key]))  
       { 
           $prod_img = $filedir.$userfile_name; 
           $prod_img_thumb = $thumbdir.$prefix.$userfile_name; 
           move_uploaded_file($userfile_tmp, $prod_img); 
           //chmod ($prod_img, octdec($mode)); 
           $sizes = getimagesize($prod_img); 
           $aspect_ratio = $sizes[1]/$sizes[0];  
           if ($sizes[1] <= $size) 
           { 
               $new_width = $sizes[0]; 
               $new_height = $sizes[1]; 
           }else{ 
               $new_height = $size; 
               $new_width = abs($new_height/$aspect_ratio); 
           } 
           $destimg=ImageCreateTrueColor($new_width,$new_height) 
               or die('Problem In Creating image'); 
           $srcimg=ImageCreateFromJPEG($prod_img) 
               or die('Problem In opening Source Image'); 
           if(function_exists('imagecopyresampled')) 
           { 
               imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) 
               or die('Problem In resizing'); 
           }else{ 
               Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) 
               or die('Problem In resizing'); 
           } 
           ImageJPEG($destimg,$prod_img_thumb,90) 
               or die('Problem In saving'); 
           imagedestroy($destimg); 
       } 
	/*switch($_FILES['image']['type'][$key]){
case 'image/jpeg':
	case 'image/pjpeg':
	case 'image/jpg':
	$bname = $_SESSION['clients'];
	
	//Alright type to cut these images up.
	$realwidth = 150;
	$realheight = 150;
	imagecreatetruecolor($realwidth, $realheight);
	

  }
}

}

Now the following errors i get are

Warning: getimagesize(../../Clients/random/images/) [function.getimagesize]: failed to open stream: Permission denied in C:\xampp\xampp\htdocs\localfind\catalogue\update\images.php on line 42

Warning: Division by zero in C:\xampp\xampp\htdocs\localfind\catalogue\update\images.php on line 43

Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in C:\xampp\xampp\htdocs\localfind\catalogue\update\images.php on line 52
Problem In Creating image


I don't see whats going on can someone help me Please!!!

#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 01 September 2006 - 04:15 AM

i think this is a folder permission problam

set to 777
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 DarkHavn

DarkHavn
  • Members
  • PipPipPip
  • Advanced Member
  • 69 posts

Posted 01 September 2006 - 04:17 AM

just set up something simple like

chmod($dir, 777); 
?

#4 DarkHavn

DarkHavn
  • Members
  • PipPipPip
  • Advanced Member
  • 69 posts

Posted 01 September 2006 - 04:41 AM

Ok scratch that last comment, i've figured out what the problem is

For some odd reason it's not picking up the name of $_FILES['image']['name'][$key];

i dunno why though, in theory it's looping through all of the <input type='file'> feilds and getting the values, but it's not picking up this one for some reason.

:S any ideas?

#5 DarkHavn

DarkHavn
  • Members
  • PipPipPip
  • Advanced Member
  • 69 posts

Posted 01 September 2006 - 04:55 AM

Ok scratch that last comment,

Figured whats going on, since it is looping through, and i havent set up anything to check if one of the upload forms are empty or not, as they don't have to upload all images, just as many as they want, (8 images all up if they want).

Now

$prod_img = "$filedir" . "$userfile_name"; 
		   echo "$prod_img<br/>";

the output of the echo is

../../Clients/random/images/Nexer_by_Mxser.jpg
../../Clients/random/images/


How would i go about fixing this one up? as i think i'm getting the errors as its trying to access the last one '../../clients/random/images' instead of the one above it.

#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 01 September 2006 - 04:58 AM

user file name needs to use the while loop or loop to echo ha.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users