r00t0101
-
Posts
8 -
Joined
-
Last visited
Never
Posts posted by r00t0101
-
-
excellent, thank you kevinkorb! Ah yea I thought the /download would point to the site_root instead of the server_root. Quick question, Is it possible to create a global site_root variable for this?
for example:
/root
/public_html
-> /example.com
-> /download.php
-> /download
-> new.txt
Could this be done. I would create a global variable named base_dir=/example.com and use $base_dir/download. My goal is to re-do the code, clean it up a bit and to re-organize the source and files into more meaningful names. By cleaning up and updating the code with global variables this would make the source more manageable.
so with your update I would like if this could be done. This is probably a bad example but if lets say for example your adding global variables to a source file full of image links where instead of changing all paths you just need to change it in once at the top.
base_dir=/example.com
$file='$base_dir/download/new.txt';
$type='text/plain';
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: ".$type);
header("Content-Disposition: attachment; filename=\"".basename($file)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file));
readfile($file);
-
excellent, thank you for the help. My layout looks similar to the layout below. Within the example.com domain is the download.php and the file new.txt is in the download folder.
/root
/public_html
-> /example.com
-> /download.php
-> /download
-> new.txt
-
ah ok, I need this to work from the site root instead of the server root. Is there a way to force it to use the site root?
-
I get file does not exist.
-
Hello all,
I am having a difficult time trying to download a file from a directory. I have tried to research this issue but each time I keep getting an empty text file instead of a ~2mb file. What I would like to have is to place my file (new.txt) in a separate folder. As of now it is under the root directory and it works fine but when I include a path then I get an error file not found.
Thanks
#########################################
#########################################
$file='/path/new.txt';
$type='text/plain';
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: ".$type);
header("Content-Disposition: attachment; filename=\"".basename($file)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($file));
readfile($file);
-
Just curious, so there is no way to use URLs in my example. Just wondering how that would work if the site is being hosted other than locally?
I tried $CFG->root = /var/www as well as some other combinations but I still get errors.
-
Hello all,
I was wondering if this could be done. I would like to re-design my site where the files being called on is using global variables instead of using syntax "../" or "../../". I would like use a more readable approach using global variables like $dir_name/file_name instead if possible. I figured this way there will only be one place to update instead of scanning through the whole file doing a search and replace on each item.
Below is a general idea of what I would like. In this example I have four files: a global, header, footer and an index file. The index file includes the global file without a problem however I had problems executing the header and footer files when using variables as seen commented.
Respectively yours,
Rick
<!-- Start testGlobal.php -->
<?
$CFG->root = "http://127.0.0.1/test";
$CFG->headerDir = "$CFG->root/header";
$CFG->footerDir = "$CFG->root/footer";
?>
<!-- End testGlobal.php -->
<!-- Start index.php -->
<?php
include("TestGlobal.php");
?>
<!-- <? echo $CFG->headerDir; ?>/header.php -->
<?php include ("./header/header.php"); ?>
bla bla bla<br><br>
<!-- <? echo $CFG->footerDir; ?>/footer.php -->
<?php include ("./footer/footer.php"); ?>
<!-- End index.php>
<!-- Start header.php -->
<html>
<head>
<title>Hello world</title>
</head>
Header Test Section<br><br>
<body>
</html>
<!-- End header.php -->
<!-- Start footer.php -->
Copyright @ test.com
<!-- End footer.php>
Trying to configure download from a specific directory
in PHP Coding Help
Posted
sorry, the question is meant towards multiple sub-domains; Is there a config file that I can create to set the site_root sorta like a jail so it does not look at the server_root?