How to make a copy of list with filenames from database?

Skodette

Registered
Nov 19, 2019
1
0
1
Europe
cPanel Access Level
Website Owner
Hi all,
I run a photography website.
In CPanel / File Manager, I can find the list with the file names of all the images (1000+) I have uploaded to my website database.

I would like to make a copy (or print) of this list, for the worst case scenario when the website and its backup file should crash.
So that I know which selected images I have to upload again from my collection on my iMac. Is this a good idea?
And how can I make a copy of the list?
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,295
1,273
313
Houston
Hi @Skodette

Making a list of 1000+ photos to upload manually sounds like an extremely time-intensive task (not just the list but the thought of re-uploading all of those!)

What might be a better bet is to keep regular backups of your site and database, that way, in the event of a catastrophic issue you'll have a copy of the site that will be restorable in minutes without the worry that you may or may not forget a file.

You can make backups directly within cPanel by going to cPanel>>Files>>Backup Wizard and download them locally or send them to a remote destination using FTP or SCP. If this feature isn't available within your cPanel UI I'd suggest discussing your options with your hosting provider further.
 
Last edited:

sbutler

Member
May 14, 2007
5
2
153
If you wanted a catalog of the photo names in a file you can create a php file. Create file photolist.php and put the code below in the file and save into a folder you want to get a text list of all the files in the folder. This will only work in the current directory and only files will be listed with no directories. This will open a save file window. Just place the file in the directory where your photos are and open the url to file,

Example:

Please note that this will not backup data. This will only give you a list of file names.


PHP:
<?php
$dir = './';

$files = scandir($dir,0);
 foreach ($files as $value) {
      if ($value > "0" && is_file($value)){
      print $value . "\n";}}

    header('Content-Type: text/plain; charset=utf-8');
    header('Content-Disposition: attachment; filename="Photo-List.txt"');
    readfile($value);
exit;
?>