I can't export (permission denied)

Talk about Printing & Exporting Settings

Moderators: ne_moj, zewa

nkd
Junior
Junior
Posts: 22
Joined: Apr 15th, '11, 22:37

I can't export (permission denied)

Postby nkd » Oct 26th, '11, 20:01

I can't get the export function to run.

In my main script I have:

Code: Select all

$exporting_directory = "mydir/";


I created "mydir" directory in the same directory as datagrid.class.php. I Applied 744 permissions. Also tried with 777.

in download.php I have:

Code: Select all

 $file_path = "../".$dir.$file;


When I try to export excel I get:
Warning: fopen(mydir/export.csv) [function.fopen]: failed to open stream: No such file or directory in /home/mydomain_com/public_html/datagrid/datagrid.class.php on line 2274

When I try to export pdf I get
Warning: fopen(mydir/export.pdf) [function.fopen]: failed to open stream: No such file or directory in /home/mydomain_com/public_html/datagrid/modules/fpdf/fpdf.php on line 1049
FPDF error: Unable to create output file: archivos/export.pdf

I have tried placing the mydir folder in the root directory, inside scrips, and in many places and it keeps telling me the same thing.

What can I do???

nkd
Junior
Junior
Posts: 22
Joined: Apr 15th, '11, 22:37

Re: I can't export (permission denied)

Postby nkd » Oct 26th, '11, 20:31

I had to hard code the path in datagrid class file and then it worked. Also, I had to hard code all the session values into the download.php script. I don't know why the session values were not working because I have session_start() in both files. The thing is that I have the data grid in a php page called from your tabs script. I don't know if that has something to do with the problem.

administrator
Site Admin
Site Admin
Posts: 5939
Joined: Jan 7th, '09, 23:18
Contact:

Re: I can't export (permission denied)

Postby administrator » Oct 27th, '11, 08:58

1. Try to download and install the latest version 7.1.5.
2. Check in datagrid if your
$this->exportMethod = "session";

We're planning to improve exporting feature in the next version

nkd
Junior
Junior
Posts: 22
Joined: Apr 15th, '11, 22:37

Re: I can't export (permission denied)

Postby nkd » Oct 27th, '11, 16:24

I installed the new datagrid version 7.1.5. Export does not work.

First problem:
I think php does not want to let fopen() to use a relative path.

Code: Select all

$fe = fopen($this->exportingDirectory."export.".$export_type, "w+");


What I had to do to fix it:
I included an absolute path (this will only work for a specific webpage)

Code: Select all

$fe = fopen('/home/mywebpage/public_html/datagrid/'.$this->exportingDirectory."export.".$export_type, "w+");



Second problem:
download.php do not receive session variables (I don't know why because session is started in both pages). because of this, it can't download the file.

What I had to do to fix it:
I changed the export method to

Code: Select all

$export_method = "NOTsession";

in both files, the datagrid class and download.php. Then variables are passed as parameters to download.php and it works fine that way.


I have read somewhere else about fopen don't working with relative paths so maybe is a good idea to add a parameter to specify an absolute path (or calculate it automatically if possible).

By the way, I tried the PDO and it didn't work so I kept using PEAR.

administrator
Site Admin
Site Admin
Posts: 5939
Joined: Jan 7th, '09, 23:18
Contact:

Re: I can't export (permission denied)

Postby administrator » Oct 28th, '11, 09:26

$export_method = "..."; is used for the cases when you have a problem with passing session variables to download.php file.
Thank you for your help, in the next version we're planning to use a hard-codded path to exporting directory,
so you will not need to write it every time you need to define exporting directory.


Return to “Settings: Printing & Exporting”