<?php $sql = "INSERT INTO ..."; mysql_query($sql); $id = mysql_insert_id(); move_uploaded_file($file, $id . '.endung'); ?>