views:

26

answers:

2

What I want to do is add a number to the beginning of the file name so I don't have a duplicate file name in the folder.

So I choose my file "example.pdf" and upload, I got the the part of the code that looks like this:

move_uploaded_file($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);

In this line of code above can I add a variable to change the file name to "1-example.pdf"?

Is that possible?

+3  A: 

You can specify the new name as part of the second parameter of move_uploaded_file:

move_uploaded_file($HTTP_POST_FILES['ufile']['tmp_name'][0], "$path1/example.pdf");

Hope this helps!

mattbasta
A: 

The move_uploaded_file method's second parameter is not only the path, but the filename to place the file. Try something like this:

move_uploaded_file($_FILES['ufile']['tmp_name'][0], $path1.'/[PUT NUMBER HERE]-'.$_FILES['ufile']['name'][0]);
Dan D.
Thanks guys, I actual figured it out right after I posted this. Thanks Again
Derrick