Situation
When POSTing a document through an API call the $_FILES var is empty. So the document is failing the document_services.php checks.
Python POST code:
def _post_document(self, pid, path, file):
file = {
'document': (file, open(file, 'rb')),
}
url = self.url + "/patient/" + str(pid) + "/document&path=/" + path
return self.session.post(url, files=file)
Configs I’ve changed:
/etc/php/7.4/apache2/php.ini
upload_tmp_dir = /var/tmp
upload_max_filesize = 100M
enable_post_data_reading = On
/etc/apache2/apache2.conf
<Directory "/var/tmp">
AllowOverride
Require all granted
</Directory>
The logs return this error because $fileData[“tmp_name”] is empty.
// Ensure filetype is allowed
if ($GLOBALS['secure_upload'] && !isWhiteFile($fileData["tmp_name"])) {
error_log("OpenEMR API Error: Attempt to upload unsecure patient document was declined");
return false;
}
I can make all other API post/put/get calls, just having the issue with document posts.
OpenEMR Version
I’m using OpenEMR version 6.0.2
Browser:
I’m using: Chrome
Operating System
I’m using: Ubuntu Server, Win10 client