Jump to content

File copying help


diar33

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
Link to comment
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.
Link to comment
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
Link to comment
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.