Jump to content

Archived

This topic is now archived and is closed to further replies.

diar33

File copying help

Recommended Posts

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

Share this post


Link to post
Share on other sites
Why do you have the same file in multiple directories?
Cant you just always link to the same one?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
use 1 folder and the index idear and name the photo via user id.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
What I do on these
Get the Unique User ID number
Get a DateStamp
I 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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.