Place uploaded files outside public_html
-
Hey there.
I am using the following filter to place files uploaded through a ACF file field in a subdir to uploads. However, I would like to place the files outside public_html instead. Is this somehow possible?
upload_dir() seems to take ../ quite literally..
add_filter('acf/upload_prefilter/name=fieldname', 'field_name_upload_prefilter'); function field_name_upload_prefilter($errors) { // in this filter we add a WP filter that alters the upload path add_filter('upload_dir', 'field_name_upload_dir'); return $errors; } // second filter function field_name_upload_dir($uploads) { // here is where we later the path $uploads['path'] = $uploads['basedir'].'/subfolder'; $uploads['url'] = $uploads['baseurl'].'/subfolder'; $uploads['subdir'] = ''; return $uploads; }
- The topic ‘Place uploaded files outside public_html’ is closed to new replies.