我可以在文件上传中为文件名添加用户ID吗?

I would like to add user ID to file name in file upload. I tried this:

$date=date("Y-m-d");
$id=mysql_insert_id();
//Abstract File codes
$info = pathinfo($_FILES['abstract']['name']);
$ext = $info['extension']; // get the extension of the file
$newname = $id."_Abstract.".$ext;
$target = "application/abstracts/";  $target = $target .$newname;
if (empty($ext)) 
{ $abstract='' ;}
else $abstract=$newname;

But I only get 0 for ID. I can display $name but $id is not working. Is it because I do not have an input for $id on my form? Thank you. I should also mention that the user is filling out an application form (for the first time) and attaching files on the same page. I had the file upload after the application was submitted I don;t think I would have problem call the $id. But since everything is on one page I might be calling an empty $id.