scdawg Posted September 5, 2012 Share Posted September 5, 2012 I'm working on a site that allows users to upload documents (pdf) to they respective directories. Then on a view page, users can click a link to the open the document for viewing. The path and filename are stored in the db and the actual document is in a directory. When I hover over the link it displays the proper path and file name, but gives me the following error: Forbidden You don't have permission to access /docs/38/test.pdf on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache Server at theleasetracker.com Port 80 If I put the files in the root, and href to them, they open as they should. The permissions of the directories are 766, but I can't get the files to open even when I set it to 777. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/268028-cant-open-files-in-directory-but-can-in-root/ Share on other sites More sharing options...
Psycho Posted September 5, 2012 Share Posted September 5, 2012 Can you show the directory structure and where - exactly - you are storing the files? Are the folders with the files in directories below the root? If not, you cannot allow the user to access them directly. But, there are solutions. So, please show the folders with the files in relation to the root and show what one of the URLs to the files that you output are. Quote Link to comment https://forums.phpfreaks.com/topic/268028-cant-open-files-in-directory-but-can-in-root/#findComment-1375500 Share on other sites More sharing options...
scdawg Posted September 5, 2012 Author Share Posted September 5, 2012 Thanks for the reply. The directory structure is www/docs/userdir/files.pdf . So the files are stored in a directory 2 directories under the root directory. I just realized I can't go to the directory in the URL and get a listing of files. Quote Link to comment https://forums.phpfreaks.com/topic/268028-cant-open-files-in-directory-but-can-in-root/#findComment-1375504 Share on other sites More sharing options...
dodgeitorelse3 Posted September 6, 2012 Share Posted September 6, 2012 are you sure it is userdir? Quote Link to comment https://forums.phpfreaks.com/topic/268028-cant-open-files-in-directory-but-can-in-root/#findComment-1375639 Share on other sites More sharing options...
Christian F. Posted September 6, 2012 Share Posted September 6, 2012 Well.. That's a 403 error, not a 404, so I'd say the path is correct. However, something is preventing the Web server from accessing the files, or serving them to the client. I'd check file permissions and web server configuration. Do check for symlinks as well, as they can be troublesome for some configurations. Quote Link to comment https://forums.phpfreaks.com/topic/268028-cant-open-files-in-directory-but-can-in-root/#findComment-1375675 Share on other sites More sharing options...
scdawg Posted September 6, 2012 Author Share Posted September 6, 2012 Just wanted to update this post with the solution. Not sure why the permissions on the server changed, but when I changed them to 755, everything works as expected. Quote Link to comment https://forums.phpfreaks.com/topic/268028-cant-open-files-in-directory-but-can-in-root/#findComment-1375758 Share on other sites More sharing options...
Christian F. Posted September 6, 2012 Share Posted September 6, 2012 Glad we could help, and thanks for posting the solution to the problem. Quote Link to comment https://forums.phpfreaks.com/topic/268028-cant-open-files-in-directory-but-can-in-root/#findComment-1375882 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.