TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Copy/Backup Folder (http://www.talkphp.com/general/2958-copy-backup-folder.html)

Jmz 06-14-2008 04:43 PM

Copy/Backup Folder
 
Is there a way I can copy a certain folder and its contents to a users computer using php?

Tree 06-14-2008 06:03 PM

If you use the user's computer as an FTP server you can. You also could zip it up and serve it for downloading.

Jmz 06-14-2008 07:34 PM

I'm not sure if we're talking about the same thing here.

When a user registers on my website it automatically creates a folder for them. Every time they upload a file it gets put into their folder. I want the user to be able to click a button in their cp and download a backup of all their files. Is this possible?

Wildhoney 06-14-2008 07:38 PM

Tree is right. You could use the ZIP archive module for doing that. The Linux method looks far easier to me, as given as an example on the PHP.net page:

php Code:
// Get the date
$date = date("m-d-y");

// Make Zip name
$zipname = "archive/site-script-backup." . $date . ".zip";

// Make a zip file
$cmd = `zip -r $zipname *`;

Jim 06-14-2008 07:41 PM

I wouldnt create folders for everyone, that way everybody can find files of another user. I would save files by a file_id and link the user with a file by a database. That way you won't have to worry about all the file handling, just uploading and deleting files. "Eitje" as we would say here in the netherlands :>

Tree 06-14-2008 07:46 PM

Quote:

Originally Posted by Jmz
I'm not sure if we're talking about the same thing here.

When a user registers on my website it automatically creates a folder for them. Every time they upload a file it gets put into their folder. I want the user to be able to click a button in their cp and download a backup of all their files. Is this possible?

In that case using FTP isn't an option. But you can still just zip/tar the user's folder and serve it. This PHP Class looks like it would work for this.

Jmz 06-14-2008 09:12 PM

Thanks for that :) I was a bit confused when you mentioned FTP.

As for people being able to find the files of other users, it shouldn't be a problem because the files will only be images to display in a gallery anyway.

Tree 06-14-2008 09:17 PM

No problem. I originally thought you wanted to build a script that backed things up to just your computer.


All times are GMT. The time now is 08:51 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0