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