[SOLVED]THUMBS.DB

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rubberjohn
Forum Contributor
Posts: 193
Joined: Fri Feb 25, 2005 4:03 am

[SOLVED]THUMBS.DB

Post by rubberjohn »

i am developing a site that relies on the only contents of a folder to be uploaded images, is there a way to stop this file being added?

if not what is the best way i can make sure it is removed regularly?

thanks
Last edited by rubberjohn on Thu May 19, 2005 5:05 am, edited 2 times in total.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

sure, just filter it out of your upload list when you use readdir or glob.
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

instead of filtering out thumbs.db:

Code: Select all

if ( $file != "thumbs.db" ) uploadFile($file);
make sure all the files you are uploading are what you want, for example by extension, etc.

If you only filter out the thumbs.db files, then you are going to upload files that you don't want to by other names.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Don't forget to filter out "." and ".." too ;)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

In that case you probably end up with an array

Code: Select all

$ignore = array('.', '..', 'thumbs.db');
And then it's only a matter of finding the right http://www.php.net/array function to filter those out...
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

Code: Select all

$ignore = array('.', '..', 'thumbs.db');
  $files = /* Function to read folder for all files */
  $validFiles = array_diff( $ignore, $files );

  uploadFiles( $validFiles );
rubberjohn
Forum Contributor
Posts: 193
Joined: Fri Feb 25, 2005 4:03 am

thanks

Post by rubberjohn »

cheers thats been a big help
Post Reply