Http Error OJS 3.3.0.7 when upload file

Describe the issue or problem
I had a problem when I wanted to upload a file. I have tried several methods, such as changing the file path, but it doesn’t work. Please help to resolve this problem. Thank You

What application are you using?
OJS 3.3.0.7

Additional information
Example error

Hi @dodyokta10,

When you get HTTP errors, it is best to check your PHP error log and report on errors found there - could you do that and report back on what you see?

-Roger
PKP Team

Below is our error log.

[28-Aug-2023 06:33:09 UTC] Slim Application Error:
Type: Exception
Message: Unable to write file at journals/1/articles/21/64ec3fa5d9b02.phtml.
File: /home/xxxxxxxxx/public_html/ojs-binacipta/lib/pkp/classes/services/PKPFileService.inc.php
Line: 83

Can you identify the problem? and give me a solution. Thank You

Hi @dodyokta10,

Is your directory for uploaded files (files_dir in the config.inc.php configuration file) configured inside your web root? If so, that is a dangerous configuration and will get your server hacked! (It’s very likely it already has been, looking at this message.) The files_dir must be placed somewhere that it can’t be accessed directly through the web server. See the configuration form, configuration file, and e.g. Admin Guide for details.

Regards,
Alec Smecher
Public Knowledge Project Team

The following is our files_dir configuration:

;;;;;;;;;;;;;;;;;
; File Settings ;
;;;;;;;;;;;;;;;;;

[files]

; Complete path to directory to store uploaded files
; (This directory should not be directly web-accessible)
; Windows users should use forward slashes
files_dir = /home/xxxxxxxx/public_html/ojs-binacipta/File

Is there anything in the configuration above that needs to be fixed? Please help. Thank you

Hi @dodyokta10,

Yes, that’s a dangerous configuration! The files_dir should not be set to something inside public_html. Move it outside of public_html and then update the files_dir to point to it.

Regards,
Alec Smecher
Public Knowledge Project Team

I have done according to what you informed me. Following are the config changes that I have made.

;;;;;;;;;;;;;;;;;;
; File Settings ;
;;;;;;;;;;;;;;;;;;

[files]

; Complete path to directory to store uploaded files
; (This directory should not be directly web-accessible)
; Windows users should use forward slashes
files_dir = /home/xxxxxxx/ojs-binacipta

but HTTP Error still appears. is there any other solution? Thank You

Hi @dodyokta10,

That’s probably a file permissions problem (judging by the error message you posted above). Make sure your file permissions are set so that OJS can upload files into the directory you’ve configured.

Regards,
Alec Smecher
Public Knowledge Project Team

I have setup the file or folder permissions according to what you suggested, but I can’t upload it yet and there is still an HTTP Error notification. the permission I use is 0777. is there another solution? Thank You

Hi @dodyokta10,

If you see an error message in your logs like the one above:

Unable to write file at /path/to/file/here

…it means that file permissions aren’t correct. There are a number of threads about this in the forum, but I can’t give specific help because the permissions you need to set will depend on your server’s configuration. If you’re using a server that runs SELinux, for example, you might need to set some additional permissions.

Note that 777 permissions are never safe to use in production, though they can be useful for debugging.

Regards,
Alec Smecher
Public Knowledge Project Team

This topic was automatically closed after 13 days. New replies are no longer allowed.