Change file name before uploading

Hey I’ve been trying to get this to work for a while but have failed. This is a 2 part question.

part 1:

I am using the file reference tutorial to upload an image to the server

http://www.kirupa.com/developer/flash8/uploading_fileReference_pg1.htm

obviously it works great. but I want to make each file upload unique, so if I upload mypicture.jpg to the server, I want to change the name of the file to mypicture1039094.jpg (or something that is unique).

part 2:

I want to also capture that new random file (mypicture1039094.jpg) in a text field so I can send it to a php script.

any and all help would be very appreciated.

Thanks.