Finding current row in PHP mySQL

Hey there, I’m fairly new to mySQL and PHP, but I have a little problem I’m wondering about the best solution to.
What I’m building is a PHP gallery, where the user uploads files to the server via a form, not a problem, the uploading all works.
The associated information is stored in a MySQL database, ie. Name, credits etc etc. And the picture is stored on server ( not using BLOBs ), the picture’s URL is saved in a field in the table.
All works fine,
What I want to do though, is set it up so that the picture is renamed to match the ID of each row. I have an auto_increment key set to give a unique ID to each picture, simple stuff.
Is there a way where I can find out what the ID of the row just added to the database is?
So the new record is added, then the server finds the ID key of the new record, and renames the picture so it’d be like ‘23.jpg’,
I know how I’d rename the picture,
Just not sure about the process I should go through finding out the ID in the process,
Any help would be greatly appreciated, I hope I articulated myself well enough here.