When I upload a file it hosts it at /app/uploads/2016/02/placeholder1.jpg
, i’ve been looking but can’t find anything.
If I want to host some PDF files, how do I change the path above for certain files only? As in, any file I upload will be hosted there as norm. But if I want to separately host a PDF to show someone, how can I change the url so it’s like /downloads/test.pdf/
?
I can’t find any plugins for this either.
Thank you.
By default all images or .pdf files are uploaded to
wp-content/uploads/
folder when you upload via media library from admin.If you want to upload .pdf files to specific folder, follow steps.
1) Create
downloads
(or any other name you want) inuploads
directory.2) Make sure to give 777 permission to
downloads
folder.3) Use filter,
add_filter('wp_handle_upload_prefilter', 'custom_upload_filter' );
to upload pdf files.4) Using
wp_handle_upload_prefilter
filter, you can change the path of the pdf files to upload incustom_upload_filter
function.For Details : https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_handle_upload_prefilter