Q
Q
Quber2014-02-18 07:44:16
PHP
Quber, 2014-02-18 07:44:16

How to fix open_basedir error when generating XSL document (using PHPExcel)?

On the local environment, the document generation is normal. On the production server, after generating the document, I try to open it in Excel. A warning pops up "The format of the file 'example.xsl' does not match the file permission. The file may be corrupted or unsafe. Do you want to open the file?" After it opens, the following content is obtained inside:
600a41fa188446238239a61ea99d8781.jpgclickable
As far as I understand, an error occurs during generation:

Warning:  realpath() [function.realpath]: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s): (/var/www/ekker/data:.) in

Tried googling but can't find a solution. It is advised to disable open_basedir. However, for security reasons, you do not want to do this. Is there another way to solve the problem?
The content of the file that generates the document
<?php

require_once 'src/vendor/PHPExcel/PHPExcel.php';
require_once 'src/vendor/PHPExcel/PHPExcel/Writer/Excel5.php';

date_default_timezone_set('Asia/Vladivostok');

$xls = new PHPExcel();

$rows = 15;

$xls->setActiveSheetIndex(0);
$sheet = $xls->getActiveSheet();
$sheet->setTitle('Consulting');

$filename = "result.xls";

header ( "Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT" );
header ( "Cache-Control: no-cache, must-revalidate" );
header ( "Pragma: no-cache" );
header ( "Content-type: application/vnd.ms-excel;" );
header ( "Content-Disposition: attachment; filename=" . $filename );

$objWriter = new PHPExcel_Writer_Excel5($xls);
$objWriter->save('php://output');

Answer the question

In order to leave comments, you need to log in

6 answer(s)
Q
Quber, 2014-02-18
@Quber

Solved the problem in a different way.
In ispmanager, the user was given permission to use PHP as CGI.
Next, in the "www domains" select the desired domain, click change and select the item "PHP as CGI"
Then everything worked .. though in my case, it was also necessary to insert the function at the beginning of the script
:

Z
ZloyHobbit, 2014-02-18
@ZloyHobbit

stackoverflow.com/questions/1846882/open-basedir-r...
Your path to /tmp is forbidden and php cannot create a temporary file.

G
GreatRash, 2015-04-29
@GreatRash

Tutorial on how to make a particle system on Canvas.
Approximately similar effect (again on particles) with the source code.

N
Nikolay Talanov, 2015-04-29
@Ronnie_Gardocki

It's done on Canvas. You need to contact those who are friends with him. I don't even know how else to say it.

C
CodeInside, 2015-04-29
@CodeInside

These libraries are used there: www.google-analytics.com/analytics.js and www.giantstepsmedias.com/assets/js/lib/modern-dete... . Animation takes place in canvas.
In general, this animation reminds me of an old joke on action-script'e, where you need to click "ok", and he runs away from you. Here the algorithm is as follows:
1) a bunch of different elements line up in their order (in this case, the letter "N") and randomly move in a small range (from which you can't exit until the "mouse" appears)
2) the mouse coordinates are read and the range is set ( here it is circular)
3) as soon as the element falls into the "large range" (mouse range) - its "small range" (d., in which it moves randomly) is shifted so

T
tim_tairan, 2015-04-29
@tim_tairan

canvas or svg contact me I can implement :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question