Welcome Guest, Not a member yet? Register   Sign In
adding timestamp to file while uploading
#1

[eluser]quest13[/eluser]
Hi,

I would like to add a timestamp value attached to file name, so that every filename becomes unique.

I tried in the following way,

$file_name = $_FILES["uploadedfile"]["name"].microtime();

but the file is saved as follows and hence corrupted

test_filename.jpg0.14866500 1252686986

Can anyone help me to solve my problem ?

I want to create each filename with unique name and want to keep the jpg format too.

Any idea ?

Thanks
#2

[eluser]LuckyFella73[/eluser]
The CI file upload library adds a number after the filename
of the just uploaded file if a file with the same name
allready exixts. So you don't have to worry about that.
#3

[eluser]Aken[/eluser]
You're adding the time in the wrong spot. The way you're doing is resulting exactly as expected. Flip flop! Oh, and microtime() would not be a good addon for a file name, since it has periods and spaces and such in it. Use time() instead.

Code:
$file_name = time() . $_FILES['uploadedfile']['name'];




Theme © iAndrew 2016 - Forum software by © MyBB