November 29, 2010

Rename and uploaded file?

Question by acctman

Is there a simple way to rename an upload file? I’d like to append $_POST['bid'] to the front of the file that was uploaded.

Answer by Starx

Rename a already uploaded file

Use rename function http://php.net/manual/en/function.rename.php

It is as easy as

rename ("/folder/file.ext", "/folder/newfile.ext");

Rename a file during upload

move_uploaded_file($_FILE['myfile'][tmp_name],$_POST['bid'].$_FILE['myfile'][name]);

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!