This PHP Tutorial explains how to rename a file while uploading and insert the same name in database in php.
Steps:
Create a form for file upload
Create a db file
rename file
move to folder
insert into database
Before renaming , get the extension of the image. For that I have used phpinfo with option extension. As that will return the extension of the file uploaded.
Phpinfo has 4 elements - directory name, basename, extension and filename.
if option is not defined, it will return array, else it will return string.
For rename, I have passed string and current date combined with randomno so that no two image will have same name.
After rename, move to folder with move_uploaded_file function in which file temporary name and directory name will be passed.
If uploaded in folder, then insert that into database table.
If you are downloading code, Create a folder upload in your project folder
Code link
https://github.com/sushma-singh-yadav...
#php #knowledgethrusters
On this page of the site you can watch the video online Rename Image while uploading using phpinfo in PHP | Move uploaded File Function with a duration of hours minute second in good quality, which was uploaded by the user Knowledge Thrusters 03 August 2020, share the link with friends and acquaintances, this video has already been watched 11,514 times on youtube and it was liked by 157 viewers. Enjoy your viewing!