Permission denied for attachment data


Active member
I use RM and would like to read attachment data with an AJAX script

My attachment data is here for example:

When I try to fetch this file with Ajax GET I receive an error message: 403 forbidden. I had a look at the file permissions: 644, so everybody should be able to read the file. What is my mistake? Do I have to use a kind of XF AJAX wrapper class?
You can't access attachment files directly via a browser. They need to be accessed through a PHP script on the server.
Ah ok, thank you @Mike . Is there already a XF function (url) I could call via AJAX to get the file or do I have to write my own php wrapper?
The URL would be the attachments route that you see when viewing an attachment to a post, for example.
I’ve tried to use the download URL within my AJAX call to fetch a file from the internal_data folder, but it also fails

Example for a single RM item with attached epub:

attachment data is here:
download link for attachment item 252:

What I should do now for my customer is to provide an URL to fetch epub data with an AJAX call for further processing. Sth. like this.
$.get( "/attachments/my_ebook-epub.252/", function( data ) {
  //We do not get any data here. The error is permission denied;
The code above fails, so I'm looking for an alternative solution. My first thought was to create a mini module only providing an additional route (/attachmentsepub/anyfile) passing data to the GET function. But hopefully there is a better and simplier solution. Thank you for any idea.
We have had this happen to a few clients but with BD Cache and Audentio styles since 1.5.7 was released.. We resolved it by running chmod -R 0777 data internal_data again in SSH
Confirm that accessing that URL directly in the works as you expect. If it does, the Ajax request should probably work. If it's not working, you may need to step through the PHP a bit to try and figure out where it's having problems.
Top Bottom