Page 1 of 1

using row id as file name

Posted: Fri Feb 06, 2009 10:01 am
by monsta-toast
hi i was just wondering how i could use the row id as a file name for images?

Code: Select all

$stock = $_POST["prod_code"];
         $size = 75; // the thumbnail height
         $filedir = 'cat_images/'; // the directory for the original image
         $thumbdir = 'cat_images/'; // the directory for the thumbnail image
         $prefix = 'small_'; // the prefix to be added to the original name
         $maxfile = '2000000';
 
at present it uses the product code which is leading to problems and as i later want to be able to change the image.

cheers :banghead:

Re: using row id as file name

Posted: Fri Feb 06, 2009 10:18 am
by Skoalbasher
On the form put the name id as a hidden field

Code: Select all

 
<input type="hidden" name="id" value="<?php echo $row['id']; ?>">

Code: Select all

 
$stock = $_POST["id"];
         $size = 75; // the thumbnail height
         $filedir = 'cat_images/'; // the directory for the original image
         $thumbdir = 'cat_images/'; // the directory for the thumbnail image
         $prefix = 'small_'; // the prefix to be added to the original name
         $maxfile = '2000000';
 

Re: using row id as file name

Posted: Fri Feb 06, 2009 10:27 am
by monsta-toast
sorry i should have said i need it to take the id for the mysql table. as i want it to use the auto increment function to make them all unique.

cheers

Re: using row id as file name

Posted: Fri Feb 06, 2009 10:30 am
by papa