spewperb Posted December 4, 2008 Share Posted December 4, 2008 Hi everyone, I'm revising a programme I wrote a few years ago for assigning uploaded files to users. Currently when an administrator logs on to assign a file to a client, a script loops through all the files in the 'uploads' directory and cross references them against a database using the files name and path as a key. This works fine however if someone amends a file and uploads it the the same directory with the same name the script assumes that it is already assigned. I was thinking about using and md5 checksum as the key. Is this a good idea? It would have to checksum several thousand video files. Can anyone think of a better way of doing this? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/135479-file-allocation-advice/ Share on other sites More sharing options...
GingerRobot Posted December 4, 2008 Share Posted December 4, 2008 Why don't you add a field to your database table which you can use to flag files as assigned or not? If someone uploads a file again, just change the value in the database. Quote Link to comment https://forums.phpfreaks.com/topic/135479-file-allocation-advice/#findComment-705804 Share on other sites More sharing options...
spewperb Posted December 4, 2008 Author Share Posted December 4, 2008 That is sort of what its doing. Files are uploaded using a ftp client (uploads not handled by the script) and sit waiting to be assigned. When a file is assigned its path is then added to the database. If you delete a file and replace it with one with an identical name the script cant tell when it does the lookup. Quote Link to comment https://forums.phpfreaks.com/topic/135479-file-allocation-advice/#findComment-705820 Share on other sites More sharing options...
premiso Posted December 4, 2008 Share Posted December 4, 2008 That is sort of what its doing. Files are uploaded using a ftp client (uploads not handled by the script) and sit waiting to be assigned. When a file is assigned its path is then added to the database. If you delete a file and replace it with one with an identical name the script cant tell when it does the lookup. Sounds like an ftp flaw/human error. You cannot really account for that unless you had some script that could tell when a file was manipulated to that directory and when it is it alerts the database that x has been deleted or b has been uploaded. The only way to do that, which I know of, would be to constantly parse the ftp logs, which would be a huge resource hog. I think you are stuck between a rock and a hard spot here. Quote Link to comment https://forums.phpfreaks.com/topic/135479-file-allocation-advice/#findComment-705955 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.