 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
ykiran
Joined: 19 Feb 2009 Posts: 2
|
Posted: Thu Feb 19, 2009 2:10 pm Post subject: Example file works on command line but not in browser |
|
|
Hi,
i have an example file containing the following code:
| Code: | <?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
# echo "<br> <b>including component...</b>";
require_once 'Spreadsheet/Excel/Writer.php';
#echo "<br> <b> Finished including.</b>";
#echo "<br> Creating a workbook";
$workbook = new Spreadsheet_Excel_Writer();
#echo "<br> sending HTTP headers...</br>";
$workbook->send('test.xls');
// Creating a worksheet
$worksheet =& $workbook->addWorksheet('My first worksheet');
// The actual data
$worksheet->write(0, 0, 'Name');
$worksheet->write(0, 1, 'Age');
$worksheet->write(1, 0, 'John Smith');
$worksheet->write(1, 1, 30);
$worksheet->write(2, 0, 'Johann Schmidt');
$worksheet->write(2, 1, 31);
$worksheet->write(3, 0, 'Juan Herrera');
$worksheet->write(3, 1, 32);
$tempdir = "/home/kiran/PEAR/temp";
echo "<br> <strong> $tempdir </strong> <br>";
if (!empty($tempdir)) {
$workbook->setTempDir($tempdir);
}
// Let's send the file
$workbook->close();
?> |
The thing is it runs without any error when running from the command line: | Quote: | | php /path/to/file/excel.php |
But, when i do the same using a browser: http://127.0.0.1/excel.php
There were errors in the Apache log:
| Quote: | [Fri Feb 20 00:49:53 2009] [error] [client 127.0.0.1] PHP Warning: Unknown: open_basedir restriction in effect. File(/var/www/html/excel.php) is not within the allowed path(s): (/usr/lib/php:/home/kiran/PEAR:/home/kiran/PEAR/temp) in Unknown on line 0
[Fri Feb 20 00:49:53 2009] [error] [client 127.0.0.1] PHP Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0
[Fri Feb 20 00:49:53 2009] [error] [client 127.0.0.1] PHP Warning: Unknown: Failed opening '/var/www/html/excel.php' for inclusion (include_path='.:/home/kiran/PEAR') in Unknown on line 0 |
What am i doing wrong here?
I am running PHP 5.2 and PEAR with Excel-Spreadsheet writer on Redhat. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1230
|
Posted: Thu Feb 19, 2009 6:07 pm Post subject: |
|
|
| You need to add /var/www/html/ to the open_basedir setting. |
|
| Back to top |
|
 |
ykiran
Joined: 19 Feb 2009 Posts: 2
|
Posted: Fri Feb 20, 2009 6:51 am Post subject: |
|
|
| mark wrote: | | You need to add /var/www/html/ to the open_basedir setting. |
Mark, thanks for the reply.
But, as soon as i did that i got the following error:
| Quote: | Warning: require_once(Spreadsheet/Excel/Writer.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/html/excel.php on line 10
Fatal error: require_once() [function.require]: Failed opening required 'Spreadsheet/Excel/Writer.php' (include_path='.:/home/kiran/PEAR') in /var/www/html/excel.php on line 10 |
This is how my open_basedir looks:
| Code: | | open_basedir = /usr/lib/php:/home/kiran/PEAR:/home/kiran/PEAR/temp:/var/www/html/ |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|