Re: Getting a "unique identifier" for a file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dinu Ionut a écrit :
SamuelDr a écrit :

Hi back,
Manuel Lemos wrote :

Hello,

on 01/28/2006 08:31 PM SamuelDr said the following:

Hi !

I'm trying to develop something in PHP.
I have a list of file, and I want to know if I can have a unique
identifier for each files. What I mean, is:

I have my files:
    test.txt
    test2.txt

I would like them to return a unique something... anything...


tempnam ?


No, actually, I do not want to create a new file, I want to associate a certain file to a certain row in a DB. I want to do some windows desktop like web application for active desktop, and want to know if there could be some sort of way to have a unique identifier to each file.
I would want this because, take this example in account :
I have dowloaded a file, movie1.avi . I delete it. 2 hours later (the wipe in the DB for old file entries is not done) I download another file with the same name. It would be place at the place of the old one ! Maybe by checking the creation date, and the filename, that would be possibkle... only quirks : if you rename the file not from the web interface... it would place itself like a new icon.


I have received this in my mail inbox... I saw that it was not there :

> I can think of that would get you a unique ID for a file that does not
> rely on the name being unique...
> 1) filename + creation date
> 2) filename + md5 hash of the contents

the first would be possible... I think.
But the second, if someone modify its files, they would get back to their default position.

Thanks anyway !

------------------------------------------------------------------------

SamuelDr a écrit :

SamuelDr a écrit :

Hi back,
Manuel Lemos wrote :

Hello,

on 01/28/2006 08:31 PM SamuelDr said the following:

Hi !

I'm trying to develop something in PHP.
I have a list of file, and I want to know if I can have a unique
identifier for each files. What I mean, is:

I have my files:
    test.txt
    test2.txt

I would like them to return a unique something... anything...


tempnam ?


No, actually, I do not want to create a new file, I want to associate a certain file to a certain row in a DB. I want to do some windows desktop like web application for active desktop, and want to know if there could be some sort of way to have a unique identifier to each file.
I would want this because, take this example in account :
I have dowloaded a file, movie1.avi . I delete it. 2 hours later (the wipe in the DB for old file entries is not done) I download another file with the same name. It would be place at the place of the old one ! Maybe by checking the creation date, and the filename, that would be possibkle... only quirks : if you rename the file not from the web interface... it would place itself like a new icon.


I have received this in my mail inbox... I saw that it was not there :

> I can think of that would get you a unique ID for a file that does not
 > rely on the name being unique...
 > 1) filename + creation date
 > 2) filename + md5 hash of the contents

the first would be possible... I think.
But the second, if someone modify its files, they would get back to their default position.

Thanks anyway !


I have received this in my inbox :

SamualDr,

You could get an MD5 hash of the file. It is extremely difficult for two
different files to have the same hash.

 Paul


It would be a good idea if my files were not meant to be modyfied, but it seems that files on the desktop WILL be modified... So, i'm still looking for something.


try md5 for file... like a hash check .... i don't know exactly how it is done... but it returns a unique identifier for a file depending on the content, type, but NOT on filename (extension)... Hope it helps!


As I said :
It would be a good idea if my files were not meant to be modyfied

But my files WILL get modified... it's SURE that they will. So md5 is not a great idea.

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux