Page 1 of 1

rename image

Posted: Tue Dec 13, 2011 11:22 am
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.

Re: rename image

Posted: Tue Dec 13, 2011 7:29 pm
by twinedev
In case you forgot, you already asked this...

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

and there were replies there...

Re: rename image

Posted: Thu Dec 15, 2011 9:57 am
by pickle
Please don't double post. You won't get more answers - especially if you post in the wrong forum. Locking topic.