• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Permission denied for attachment data

rhodes

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

My attachment data is here for example:
/internal_data/attachments/0/252-b798673db57fd915cd46d6c44c63d6ad.data

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?
 

Mike

XenForo developer
Staff member
#2
You can't access attachment files directly via a browser. They need to be accessed through a PHP script on the server.
 

Mike

XenForo developer
Staff member
#4
The URL would be the attachments route that you see when viewing an attachment to a post, for example.
 

rhodes

Active member
#5
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:
/internal_data/attachments/0/252-b798673db57fd915cd46d6c44c63d6ad.data
download link for attachment item 252:
/attachments/my_ebook-epub.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.
Code:
$.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.
 

Mike Edge

Well-known member
#6
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
 

Mike

XenForo developer
Staff member
#7
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.