Title: Programmatically get file path from id
Last modified: March 16, 2023

---

# Programmatically get file path from id

 *  Resolved [Mad Max](https://wordpress.org/support/users/mad_max/)
 * (@mad_max)
 * [3 years ago](https://wordpress.org/support/topic/programmatically-get-file-path-from-id/)
 * Hello, I’m a developer and I’m writing some code to dynamically add a Download
   Monitor file to an Elementor form email message, as attachment, using the file
   id.
   Following documentation on plugin website, I was able to retrieve the url
   of a download by its id, with this code:
 *     ```wp-block-code
       $file_id=1218;
       $file = download_monitor()->service( 'download_repository' )->retrieve_single( $file_id );
       $fileurl = $file->post->guid;
       ```
   
 * How can I retrieve the file’s full local path?
    -  This topic was modified 3 years ago by [Mad Max](https://wordpress.org/support/users/mad_max/).

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Razvan Aldea](https://wordpress.org/support/users/raldea89/)
 * (@raldea89)
 * [3 years ago](https://wordpress.org/support/topic/programmatically-get-file-path-from-id/#post-16565980)
 * Hello [@mad_max](https://wordpress.org/support/users/mad_max/) ,
   You can use 
   our File Manager class to retrieve the path of the file: [https://github.com/WPChill/download-monitor/blob/master/src/FileManager.php#L47](https://github.com/WPChill/download-monitor/blob/master/src/FileManager.php#L47)
   depending on your found `$fileurl`.Hope this helps!Warmly,Razvan
 *  Thread Starter [Mad Max](https://wordpress.org/support/users/mad_max/)
 * (@mad_max)
 * [3 years ago](https://wordpress.org/support/topic/programmatically-get-file-path-from-id/#post-16567004)
 * Hello [@raldea89](https://wordpress.org/support/users/raldea89/) and thanks for
   the super quick reply! 
   I’ve tried the method `parse_file_path( $file_path )`
   of class **DLM_File_Manager**, but it always return an array with 2 empty elements,
   if called with my file url that is like this
 *     ```wp-block-code
       https://mysite.ext/download/2378/?tmstv=1678986055
       ```
   
 * where obviously “download” is the configured endpoint for downloads and the links
   correctly starts the download of the file when pasted in a browser address bar.
 * Any advice?
 * Regards
 *  [Razvan Aldea](https://wordpress.org/support/users/raldea89/)
 * (@raldea89)
 * [3 years ago](https://wordpress.org/support/topic/programmatically-get-file-path-from-id/#post-16568445)
 * Yes, I misunderstood what you have retrieved, sorry. 
   You have the Download Object,
   so you can retrieve the file paths like [here](https://github.com/WPChill/download-monitor/blob/master/src/DownloadHandler.php#L372).
   This will return an array of paths, from which you can choose one. After that
   you can use the File Manager Class I’ve mentioned before.You can inspire from
   our [trigger](https://github.com/WPChill/download-monitor/blob/master/src/DownloadHandler.php#L363)
   function in order to achieve what you want.Warmly,Razvan
 *  Thread Starter [Mad Max](https://wordpress.org/support/users/mad_max/)
 * (@mad_max)
 * [3 years ago](https://wordpress.org/support/topic/programmatically-get-file-path-from-id/#post-16568712)
 * Thank you very much for pointing me in the right direction!
 *  [Razvan Aldea](https://wordpress.org/support/users/raldea89/)
 * (@raldea89)
 * [3 years ago](https://wordpress.org/support/topic/programmatically-get-file-path-from-id/#post-16568714)
 * Gladly 😀 !
   Have a wonderful day!Razvan

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Programmatically get file path from id’ is closed to new replies.

 * ![](https://ps.w.org/download-monitor/assets/icon-256x256.png?rev=3198936)
 * [Download Monitor](https://wordpress.org/plugins/download-monitor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/download-monitor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/download-monitor/)
 * [Active Topics](https://wordpress.org/support/plugin/download-monitor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/download-monitor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/download-monitor/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Razvan Aldea](https://wordpress.org/support/users/raldea89/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/programmatically-get-file-path-from-id/#post-16568714)
 * Status: resolved