diar33 Posted August 2, 2006 Share Posted August 2, 2006 Hi there, I am trying to change one file in about 300 directories, all of which reside in one main directory. The file is the same in each. Is there a way to copy a new file into each of these directories to overwrite the old one automatically using php?Thanks in advance,TValdes Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 2, 2006 Share Posted August 2, 2006 Why do you have the same file in multiple directories?Cant you just always link to the same one? Quote Link to comment Share on other sites More sharing options...
diar33 Posted August 3, 2006 Author Share Posted August 3, 2006 Here's teh situation: Members of the site are allowed to post photos, which are stored in randomly named directories. The server the site's on wont allow for much security, so in the case that someone finds the folder name, they will be able to see that members photos even if not a member of the site. To fix that, there is an index file in each directory which throws them back to the site's index. However, it goes to a bad link, actually another site I did the same thing for.. which is bad. Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 3, 2006 Share Posted August 3, 2006 use 1 folder and the index idear and name the photo via user id. Quote Link to comment Share on other sites More sharing options...
ryanlwh Posted August 3, 2006 Share Posted August 3, 2006 if you could and if your host allows it, add a .htaccess file in your root and deny access to file having the image extensions. Quote Link to comment Share on other sites More sharing options...
diar33 Posted August 3, 2006 Author Share Posted August 3, 2006 Those wouldn't work, as the host doesn't allow .htaccess, and the members are allowed to have multiple photos, though it could still be done this way I suppose.Either way, I still need a way to change what's currently there, as there are over 300 members with pictures and going through each and changing it is a complete nightmare. The site is live and I couldn't just go and delete everyone's current pictures.Thanks for the replies,TValdes Quote Link to comment Share on other sites More sharing options...
onlyican Posted August 3, 2006 Share Posted August 3, 2006 What I do on theseGet the Unique User ID numberGet a DateStampI normally only have one upload as its for profiles so this will do for me[code=php:0]$user_id = $id; //This is the users unique ID$stamp = date("Y-m-d H:i:s");$new_file_name = $id."_".$date.".".$ext[/code]The name is always unique, this stops against accidently overwriting.//I Normally get the file ext, to check it is jpg || gif..... That is what the $ext is Quote Link to comment 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.