User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

snippets:drupal:download-drupal-module-file [2018/04/26 01:35] (current) created
Line 1: Line 1:
 +===== Download Drupal Module File =====
 +There are times when you may need to access Drupal code files, but don't actually have SSH or FTP configured on your server - maybe you want to verify that some other syncing mechanism or VCS is working as intended. In such instances, assuming you have admin access to the server in question, you can use the following workaround to download your code. First enable the PHP filter module, then create a new node with said filter, pasting the following code in the node's body:
 +    <?php
 +    ​
 +    ob_end_clean();​
 +    ​
 +    $filepath = "​sites/​default/​modules/​mytest/​mytest.module";​
 +    $realpath = realpath($filepath);​
 +    ​
 +    drupal_add_http_header("​Content-Type",​ "​text/​plain"​);​
 +    drupal_add_http_header("​Content-Disposition",​ "​attachment;​ filename=code.txt"​);​
 +    drupal_send_headers();​
 +    ​
 +    echo file_get_contents($realpath);​
 +    ​
 +    drupal_exit();​
 +    ​
 +    ?>
 +    ​
 +    ​
 +Once you've entered that code into the body field for a temporary node (again, being sure to select the PHP code filter from the Text Formats list) you can hit "​Preview"​ to initiate the download.
snippets/drupal/download-drupal-module-file.txt ยท Last modified: 2018/04/26 01:35 by