rename image

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Locked
abbey4biz
Forum Commoner
Posts: 32
Joined: Wed Nov 23, 2011 12:25 pm

rename image

Post by abbey4biz »

Hello Programmers,

Please can somebody give me the codes that can be used rename an uploaded image in the database, using php and mysql, probably to rename the image to the id number of the field.

Below is the code I have used to upload the image to a folder on the server with the link of the image in the database.
Thanks.

if (isset($_FILES['upload'])) {


// Validate the type. Should be JPEG or PNG.

$allowed = array ('image/pjpeg', 'image/jpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG',
'image/PNG', 'image/png', 'image/x-png');

if (in_array($_FILES['upload'] ['type'], $allowed)) {

// Move the file over.

if (move_uploaded_file ($_FILES['upload']['tmp_name'], "uploads/{$_FILES['upload']['name'] }")) {




$temp = ("uploads/{$_FILES['upload']['name'] }");


if (empty($errors)) { // If everything’s OK.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: rename image

Post by twinedev »

In case you forgot, you already asked this...

viewtopic.php?f=1&t=133437&p=667547

and there were replies there...
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: rename image

Post by pickle »

Please don't double post. You won't get more answers - especially if you post in the wrong forum. Locking topic.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Locked