Page 1 of 1

updating file names

Posted: Mon Aug 21, 2006 8:56 am
by hame22
Hi all

one of our employees has added files to our site with spaces rather than hyphens. This measn we are experiencing problems when people using mozilla try to download one of these files.

Is it possibe to produce a script which takes the value of the file name (which is stored in a database field) and places hyphens, '-' instead of a space and then updates with this new value?


thanks in advance

Posted: Mon Aug 21, 2006 9:07 am
by feyd
Yes, it's possible.

Posted: Mon Aug 21, 2006 9:11 am
by onion2k
Yeah. Just grab the name from the database, use str_replace() to fix the spaces, then use PHP's rename() function to rename all the files. And then update the value in the database so that they're correct too.

And finally make sure whatever script you're using to upload files to your site doesn't let it happen again.