How to Add Uploaded Media to WP-DownloadManager
If you imported all of the forms, and want the file sizes to show up in the database, there is a script that you can put into a php file that will populate all of the file sizes into the database. Thanks Lester for helping this along!
I put this in my “single.php” file, but I would guess that you could throw it in any file. You’ll put this php code into one of the templates in your theme (single.php, page.php, etc), load the page once so that it will gather all of the info, then you’ll need to remove it from the php file. It will populate the database, but in the process, it will throw a warning for each file and display it in your browser. Trust me, it does not look pretty; you get a page full of warnings all over your website. Best to use an unused template or something that no one else will come across.
But it works, or at least it did on my configuration (I’m running an Ubuntu dedicated server). Here you go:
<?php
$filesizes = $wpdb->get_results("SELECT file FROM wp_downloads");
$location = "/var/www/wp-content/uploads/";
foreach($filesizes as $fsize) {
$name = $fsize->file;
$size = filesize($location.$name);
echo $size;
$wpdb->query("UPDATE wp_downloads SET file_size='$size' WHERE file = '$name'");
} ?>





Thank for Information
Hi, cool post. I have been wondering about this topic,so thanks for writing.
Thanks for your valuable information. I will try it……
Thank you for this post. This is what I’m looking for.