Jump to content


Photo

Why arent my images getting to the server?


  • Please log in to reply
2 replies to this topic

#1 laide234

laide234
  • Members
  • PipPipPip
  • Advanced Member
  • 33 posts

Posted 10 August 2006 - 10:23 PM

I think my code is fine. But the images arent even getting to the server. Please take a look at my function:


function modifyProduct()
{
$path = $_SERVER['DOCUMENT_ROOT'];
$dirname = '/images/product/';
$chmod = 0755;

// create file vars to make things easier to read.
$filename = $_FILES['fleImage']['name'];
$filesize = $_FILES['fleImage']['size'];
$filetype = $_FILES['fleImage']['type'];
$file_tmp = $_FILES['fleImage']['tmp_name'];
$file_err = $_FILES['fleImage']['error'];
$file_ext = strrchr($filename, '.');

$productId  = (int)$_GET['productId'];
        $catId      = $_POST['cboCategory'];
        $name        = $_POST['txtName'];
$description = $_POST['mtxDescription'];
$price      = str_replace(',', '', $_POST['txtPrice']);
$qty        = $_POST['txtQty'];

$scost      = str_replace(',', '', $_POST['txtScost']);
$ropoint    = $_POST['txtRop'];

$dir = $path . $dirname;
$prefix = substr($filename, 0, -4);
$thumb = "_t";
$thumbnail = $prefix . $thumb . $file_ext;

// if uploading a new image (filename field is not empty)
// remove old image
if ($filename != '') {
_deleteImage($productId);
if (@move_uploaded_file($file_tmp, $dir . '/' . $filename))
{

$n_w = 240;
$n_h = 240;
$t_w = 75;
$t_h = 75;
$o_path = " ";
$s_path = " ";
Resize_Image($dir . '/' . $thumbnail,$dir . '/' . $filename,$t_w,$t_h,$s_path,$o_path);
Resize_Image($dir . '/' . $filename,$dir . '/' . $filename,$n_w,$n_h,$s_path,$o_path);

$filename = "'$filename'";
$thumbnail = "'$thumbnail'";
}
else
{
// error moving file. check file permissions.
unlink($file_tmp);
echo '<strong>Error:</strong> Unable to move file to designated directory.';
}
} else {
// if we're not updating the image
// make sure the old path remain the same
// in the database
$filename = 'pd_image';
$thumbnail = 'pd_thumbnail';
}

$sql  = "UPDATE tbl_product
          SET cat_id = $catId, pd_name = '$name', pd_description = '$description', pd_price = $price,
      pd_qty = $qty, pd_image = $filename, pd_thumbnail = $thumbnail, pd_scost = $scost, pd_ropoint = $ropoint
  WHERE pd_id = $productId"; 

$result = dbQuery($sql);

header('Location: index.php');  
}

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 10 August 2006 - 10:46 PM

Try removing the @ error suppression from your code. Ensure that $dir has appropriate permissions. Echo the full value of $dir and $thumbnail to see if they are 'correct' values.
Legend has it that reading the manual never killed anyone.
My site

#3 laide234

laide234
  • Members
  • PipPipPip
  • Advanced Member
  • 33 posts

Posted 11 August 2006 - 01:47 AM

you are absolutely right!! it was the path. I had switched directories and forgot to update

$dirname = '/images/product/';




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users