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.
rename image
Moderator: General Moderators
Re: rename image
In case you forgot, you already asked this...
viewtopic.php?f=1&t=133437&p=667547
and there were replies there...
viewtopic.php?f=1&t=133437&p=667547
and there were replies there...
Re: rename image
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.