Get filepath to uploaded files
-
I want to process the uploaded files, in a
fu_after_upload
action. In particular, I want to know the path names of the newly uploaded files. Where can i get this information?I have added the following code to
wp-content/themes/mytheme/functions.php
:add_action( 'fu_after_upload', 'my_fu_after_upload', 10, 3 ); function my_fu_after_upload( $attachment_ids, $success, $post_id ) { // do something with freshly uploaded files // This happens on POST request, so $_POST will also be available for you echo '<p>attachment_ids</p><pre>'; print_r($attachment_ids); echo '</pre>'; echo '<p>success</p><pre>'; print_r($success); echo '</pre>'; echo '<p>post_id</p><pre>'; print_r($post_id); echo '</pre>'; echo '<p>_POST</p><pre>'; print_r($_POST); echo '</pre>'; echo '<p>_FILES</p><pre>'; print_r($_FILES); echo '</pre>'; }
This prints out, among other useful details, an array of the
name
s of the uploaded files and an array of thetemp_name
s of each uploaded file (a relative path), but the files are then moved to a folder at…/wp-content/uploads/YYYY/MM/
… where YYYY is the four-digit year and MM the two-digit month.
Is there a way to get the full paths automatically, or must I manually recreate this from the current date and the original file
name
?
- The topic ‘Get filepath to uploaded files’ is closed to new replies.