Title: Email attachment missing
Last modified: April 18, 2018

---

# Email attachment missing

 *  Resolved [robinzimmer1989](https://wordpress.org/support/users/robinzimmer1989/)
 * (@robinzimmer1989)
 * [8 years ago](https://wordpress.org/support/topic/email-attachment-missing/)
 * Hi there, first of all: Your plugin is awesome, thank you so much for this!
 * I just have a tiny issue with email attachments. I’m using a file upload field
   with the ‘basic’ uploader. And everything is working fine here: The file gets
   uploaded to the server and the saved form entry contains the link to the file!
   But for some reason it’s not showing up in the email. Below the field name is
   just an “h” with no link. Do you know what to do?
 * Let me know if you have any questions.
 * Best regards
    Robin
 * $args = array(
    ‘uploader’ => ‘basic’, ‘submit_text’ => ‘Send Request’ );
 * advanced_form( ‘form_5acfceaaac1de’, $args );

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

 *  Plugin Author [fabianlindfors](https://wordpress.org/support/users/fabianlindfors/)
 * (@fabianlindfors)
 * [8 years ago](https://wordpress.org/support/topic/email-attachment-missing/#post-10198899)
 * Hi and thank you!
 * I just tried a similar scenario with the basic uploader and the file with link
   showed up in the email. Could you check if your uploads directory contains the
   file after submission?
 *  Thread Starter [robinzimmer1989](https://wordpress.org/support/users/robinzimmer1989/)
 * (@robinzimmer1989)
 * [8 years ago](https://wordpress.org/support/topic/email-attachment-missing/#post-10199514)
 * Hi Fabian, okay I guess I found the error:
    I changed the return value of the
   acf field from “File URL” to “File Array” and now the link is showing up in the
   email.
 * Is there a way to change the filename during the upload process with a hook?
 * Best regards
    Robin
 *  Plugin Author [fabianlindfors](https://wordpress.org/support/users/fabianlindfors/)
 * (@fabianlindfors)
 * [8 years ago](https://wordpress.org/support/topic/email-attachment-missing/#post-10205630)
 * That sounds like a good solution! I might add better support for file fields 
   in a future release with support for both “File URL” and “File array”.
 * Regarding uploads it might be a challenge. My plugin uses a function provided
   by ACF to automatically handle uploads and unfortunately ACF doesn’t provide 
   any hooks for it. There does exist a WordPress hook which is triggered whenever
   a file is uploaded called `wp_create_file_in_uploads` ([https://developer.wordpress.org/reference/hooks/wp_create_file_in_uploads/](https://developer.wordpress.org/reference/hooks/wp_create_file_in_uploads/)).
   You could probably hook into this, check if `AF()->submission` is not null, and
   then change the file name. I realize this is quite cumbersome but it seems to
   be the best solution for the moment. Hopefully I can provide my own uploading
   implementation in the future with better hooks!
 * Hope this helps!
 *  Thread Starter [robinzimmer1989](https://wordpress.org/support/users/robinzimmer1989/)
 * (@robinzimmer1989)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/email-attachment-missing/#post-10287439)
 * Hi Fabian, I’ve found a nice hook to change the filename, but I have problems
   to check for a AF form submission as you suggested. For now I just check if the
   file gets uploaded via the frontend or backend by inspecting the url.
 * Do you have a more elegant solution for this?
 *     ```
       <?php
       function renameUploadedFiles($filename) {
   
           $info = pathinfo($filename);
           $ext  = empty($info['extension']) ? '' : '.' . $info['extension'];
   
           $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
   
           if (strpos($url, 'wp-admin') == false):
               $filename = bin2hex(openssl_random_pseudo_bytes(16));
           endif;
   
           return $filename . $ext;
       }
       add_filter('sanitize_file_name', 'renameUploadedFiles', 10);
       ?>
       ```
   

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

The topic ‘Email attachment missing’ is closed to new replies.

 * ![](https://ps.w.org/advanced-forms/assets/icon-256x256.png?rev=1894254)
 * [Advanced Forms for ACF](https://wordpress.org/plugins/advanced-forms/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/advanced-forms/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/advanced-forms/)
 * [Active Topics](https://wordpress.org/support/plugin/advanced-forms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/advanced-forms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/advanced-forms/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [robinzimmer1989](https://wordpress.org/support/users/robinzimmer1989/)
 * Last activity: [7 years, 12 months ago](https://wordpress.org/support/topic/email-attachment-missing/#post-10287439)
 * Status: resolved