How to change upload file's name


In yii FW, there are provided us a CUploadedFile in order to upload filed to server. But, can I rename the file uploaded by users. I want to make each file uploaded by users are indicated by a difference name.

I plan to change file’s name of uses upload to a numberic value (using time() function to edit the file name. For example: if user uploads a image file named: imageUpload_1.jpg, so, I want to edit the file name to cuurent time: 109231391.jpg)

Have every one ever did it?


Just give the "new" name as a parameter to saveAs -


Based on your solution, is it possible to rename the folder ? Currently already successful create a folder with user specific name. But if user want to change name, so i would like to rename this folder based on user enter without losing any document in that folder.

This thread is about uploading a file and giving it a new name…

What you need is a way to rename a folder… for that you can use PHP function rename() -