CSV files not auto-generated in /media folder

In my Kirby 3 project (Kirby version 3.1.3) I use a csv-to-table plugin based on https://github.com/lauriiii/csv-to-table.

For all the pages that contain data visualizations I placed an individual csv file in the specific /content folders which are visualized in a nice way. In my local test environment (Windows + XAMPP) everything works fine, means the csv files are auto-generated in the /media folder and are visualized with the help of the csv-to-table plugin as soon as I am navigating to one of the pages that contain a csv file.

BUT when I am moving all the content to a remote test server (with a cleaned up /media folder) the auto-generation of csv files in the /media folder does not work anymore, so the csv-to-table plugin is not able to find the csv file. The auto-generation of image files (jpg, png, etc. ) in the /media folder is working correctly.

Did anyone else observe this behavior?

What version of PHP are you running on the remote server? A wild shot, but maybe mime types have not been properly configured for CSV.

What happens if you access the file directly in a template, as a file object? Does it end up in the media folder? Im basically trying to work back from what the plugin is doing and see if its the problem, or wether its a wider server / kirby problem with accessing CSV files.

Is the plugin you made in a public repo somewhere that you can share with us?

I guess the problem could even be the CSV files themselves - do they have they correct BOM etc? They might work locally but perhaps not on a different operating system.

In principle, if the file is only used by PHP and not accessed by the user, it doesn’t even have to be publicly available in the media folder. The reason why it doesn’t work is probably that the plugin uses the URL (that points to the media folder) to access the file rather than the file root.

@jimbobrjames
The remote server runs PHP Version 7.2.17
The plugin tries to open
$handle = fopen($file->url(), “r”)
with $file->url() refering to a generated csv copy in the /media folder, e.g.
http://myserver/media/pages/blablabla/4251305460-1556536094/myfile.csv
but this file does not exist / was not created.

On my local machine the csv file copy is properly created in /media and above mentioned file access method works properly.

@texnixe
This could be a workaround indeed but due to the fact that it works in the local test environment but the auto generation fails in another server environment there might be some problem with the auto generation procedures…?

But since images work and it worked locally, this is probably not a Kirby problem, but maybe a problem with the file and/or the server settings. Could you please try the root() method instead of the url() method. That way we can maybe rule out that the file is generally unreadable on the remote server. I’m not trying to sell that as a solution.

The root() method works fine.

Additinally I tried to access the file by manually entering the URL in the browsers URL bar.
http://myserver/media/pages/blablabla/4251305460-1556536094/myfile.csv
This forces the auto generation in the /media folder but even the file exists now the access with the url() method fails.

Ok, could you please turn on debugging on the remote server, and just try to call the file in the page template

echo $page->file('name-of-file.csv')->url();

echo $page->file(‘myfile.csv’)->url();

returns

http://myserver/media/pages/blablabla/4251305460-1556536094/myfile.csv

Ok, and if you do that, the file is also copied into the media folder like it should be?

No unfortunately it is still not created in the /media folder.

Hm, I don’t have an answer. It’s a bit weird that the file gets created if you open in the browser but not otherwise.

I think for the purposes of your tag, you can live with the root() method for the moment.

Ok, thank you for your support.
I will use the root() method for the moment and maybe do some additional tests during the next days.