publish .pdf of .doc files

RolandBlue
Jr. Bludit
Posts: 2
Joined: Wed May 23, 2018 9:19 pm

Hi,
I made a bludit site for a small public library. There is a need to share a few .doc and .pdf files.
How can this be managed using the admin web interface ? I tried uploading the file as an image but it does check the extension and only jpg, jpeg, gif and png are allowed and thus cannot be done this way.

Thank you for your help,

Roland
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

The types are set in in the file uploader.php (in the directory /bl-kernel/ajax/).

To allow the uploading of PDF files the array $validExtension can be modified as follows (line 18):

Code: Select all

$validExtension = array('tiff', 'gif', 'png', 'jpg', 'jpeg', 'bmp', 'svg','pdf')
See also Upload von PDF-, Audio- und Video-Dateien.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
RolandBlue
Jr. Bludit
Posts: 2
Joined: Wed May 23, 2018 9:19 pm

Thank you. I can upload pdf this way. I does need some documentation to link to the pdf as you cannot have the name of the file once uploaded.
I think it will do the job or I will upload the files with an FTP client.

Roland
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

RolandBlue wrote: Wed May 30, 2018 10:50 pm I can upload pdf this way. I does need some documentation to link to the pdf as you cannot have the name of the file once uploaded.
Yes, there are some restrictions naming files at the moment.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
Kao
Jr. Bludit
Posts: 2
Joined: Tue Aug 06, 2019 1:58 pm

Hi all,

I hope you can help me: I want to upload .pdf using the admin web interface, and the suggested solution does not work (Bludit 3.9.2).

In fact, in my upload-images.php, there is no $validExtension array which I can change.
I didn't found it on other places either. Why?

In the directory /bl-kernel/admin/themes/booty/html/ I found this code in the media.php
const validImageTypes = ['image/gif', 'image/jpeg', 'image/png', 'image/svg+xml'];

and in bl-kernel/boot/variables.php there is
// Allowed image extensions
$GLOBALS['ALLOWED_IMG_EXTENSION'] = array('gif', 'png', 'jpg', 'jpeg', 'svg');
but it does not work if I add .pdf to either one or both of this codes.
If I try to upload a .pdf after adding it there, I get the message
File type is not supported. Allowed types: gif, png, jpg, jpeg, svg, pdf
Any ideas what is going wrong and how to fix it?

Thank you,

Kao
User avatar
Jay
Master Bludit
Posts: 133
Joined: Mon Feb 11, 2019 8:41 pm

Kao wrote: Tue Aug 06, 2019 2:32 pm Any ideas what is going wrong and how to fix it?
You were heading in the right direction as things changed in B 3.9.X
Basically you need to
1. add a valid mime type of the files you want to upload in validImageTypes array
For pdf files add:

Code: Select all

application/pdf


2. add allowed file extension in ALLOWED_IMG_EXTENSION variable, which you have already done judging by the error message

edit, save, upload changes, and let us know if everything works as supposed ;)
Kao
Jr. Bludit
Posts: 2
Joined: Tue Aug 06, 2019 1:58 pm

Thank you Jay!

It worked! In my first try, I did not know that it is named "application" before the slash!
saum
Jr. Bludit
Posts: 7
Joined: Thu Oct 17, 2019 8:15 am

I also applied the changes to upload a pdf file, which is working! :)

But how do I create a link to the pdf file?
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

As HTML link (with the absolute path to the file).
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
jmonroe
Sr. Bludit
Posts: 38
Joined: Mon Feb 22, 2016 8:06 am
Location: USA
Contact:

This is good information to know. Thanks
Jeremy Monroe
I Support Bludit via Patreon
Post Reply