using row id as file name

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
monsta-toast
Forum Newbie
Posts: 16
Joined: Sat Jan 17, 2009 3:21 pm
Location: NEWCASTLE UPON TYNE

using row id as file name

Post 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:
User avatar
Skoalbasher
Forum Contributor
Posts: 147
Joined: Thu Feb 07, 2008 8:09 pm

Re: using row id as file name

Post 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';
 
User avatar
monsta-toast
Forum Newbie
Posts: 16
Joined: Sat Jan 17, 2009 3:21 pm
Location: NEWCASTLE UPON TYNE

Re: using row id as file name

Post 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
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: using row id as file name

Post by papa »

Post Reply