Jump to content


This topic is now archived and is closed to further replies.


Couple of simple errors i can't fix

Recommended Posts

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!';

// 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];
              $new_height = $size;
              $new_width = abs($new_height/$aspect_ratio);
              or die('Problem In Creating image');
              or die('Problem In opening Source Image');
              or die('Problem In resizing');
              or die('Problem In resizing');
              or die('Problem In saving');
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!!!

Share this post

Link to post
Share on other sites
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?

Share this post

Link to post
Share on other sites
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).


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

the output of the echo is


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.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.