This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Embed uploaded images directly in sent email


  1. halbtuerke
    Member

    Hi,

    is there a way that instead of providing a download link to an image directly embed it into the email which gets send to me?
    I looked at the folder structure on my web space and can locate the images but in the email I only get an option to download it instead of directly embedding it via an <img> tag.

    Thanks in advance

    Posted 16 years ago #
  2. AMurray
    Pro Member

    I suppose you could do this (note this is all assumption).

    In your email template, add the HTML code: <img src={Element_x}> where "Element_x" is the field holding the location of the image. I think you can actually use basic HTML tags in the message, provided your email program reads HTML emails.

    Not sure if it would work. But it may do. You can pick and choose the field names for the Email template - the message you're sending to yourself, or the user.

    Since, by default, the message provides a link, it may require digging into the code and modifying it with a <img>tag rather than an <a href>.

    Posted 16 years ago #
  3. halbtuerke
    Member

    Thanks for your response. I will see what I can find in the source code and try to modify it to my needs.

    Posted 16 years ago #
  4. yuniar

    Hmm.. what about attaching the images, instead of embed?


    MachForm Founder

    Posted 16 years ago #
  5. halbtuerke
    Member

    My co-worker wants to see the images directly in the emails without having to open it in a separate program.

    It's an application form where the people have to send us images of themselves and he wants it to look like a "regular" application where you can actually see the image beside the information.

    Greetings

    Posted 16 years ago #
  6. yuniar

    Try this,

    1) Edit your includes/entry-functions.php file, search around line 395 for this code:

    $entry_details[$i]['value'] = '<img src="'.$options['machform_path'].'images/icons/attach.gif" align="absmiddle" />&nbsp;<a class="entry_link" href="http'.$ssl_suffix.'://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/download.php?q='.$q_string.'">'.$filename_value.'</a>';

    replace it with this one:

    $entry_details[$i]['value'] ='<img src="http'.$ssl_suffix.'://'. $_SERVER['HTTP_HOST'] .dirname($_SERVER['PHP_SELF']) .  '/data/form_' . $form_id . '/files/element_' . $element_id . '-'.  $file_1  . '" /> ';

    2) Edit includes/helper-functions.php file, search around line 349 for this code:

    $data['value'] = strip_tags($data['value'],'<a>');

    replace it with this one:

    $data['value'] = strip_tags($data['value'],'<a><img>');

    That would show the image into your email.


    MachForm Founder

    Posted 16 years ago #
  7. halbtuerke
    Member

    Thank you very much for your help. I will test it later and i will report back how everything went.

    Posted 16 years ago #
  8. macat
    Member

    Well I tried it and it works fine, thanks.

    Belinda
    happiness is being owned by cats ...
    http://BelindaSauro.com

    Posted 16 years ago #
  9. M202A1
    Member

    This code change has not worked for me.

    Posted 15 years ago #
  10. redityo

    Hi,

    Hmm .. The code should be work fine, anyway could you send your modified file to :

    customer.service[at]appnitro.com

    I will check it


    MachForm Support

    Posted 15 years ago #
  11. M202A1
    Member

    Works fine now.

    Posted 15 years ago #
  12. mav2u
    Member

    Anyway to remove the naming it attaches to the photo?

    Also, can it be added as a attachment to an email? Instead of embedding it in the email? If I had 4 upload image fields it would be nice to just have it as an attachment that I can open the email, save those four images quickly and move on.

    Thanks,
    Jeremy

    Posted 15 years ago #
  13. mav2u
    Member

    When I made the changes mentioned above it worked good for photos. Any other file format showed a broken image link with now download link.

    So no link to get the .pdf file that was uploaded.

    The code was in the email. <td width="60%" style="border-bottom:1px solid #DEDEDE;padding:5px 10px;"><img src="http://mydomain.com/machforms/data/form_5/files/testadobe.pdf" /> </td>

    Nothing to link the src= to a viable text link any more. Email shows up blank.

    any thoughts to this?

    Jeremy

    Posted 15 years ago #
  14. yuniar

    The code above only intended for images, since the point is to show the image directly. It won't work for any other file types.


    MachForm Founder

    Posted 15 years ago #
  15. thizzle
    Member

    This works fine ONLY if the file being uploaded does NOT have spaces in the filename! is there a fix for that?

    Posted 15 years ago #
  16. yuniar

    What happened if the file being uploaded having spaces? Can you paste the generated code?


    MachForm Founder

    Posted 15 years ago #
  17. vinchenze
    Member

    Did anything change? I tried the above but am getting the broken image icon when viewing the email. I checked and double checked the code / changed code in both includes/entry-functions.php and includes/helper-functions.php. I also made sure the uploaded images had no spaces. Any help would be appreciated.

    Posted 14 years ago #
  18. redityo

    There is an update for that code, try to replace this code :

    $entry_details[$i]['value'] ='<img src="http'.$ssl_suffix.'://'. $_SERVER['HTTP_HOST'] .dirname($_SERVER['PHP_SELF']) .  '/data/form_' . $form_id . '/files/element_' . $element_id . '-'.  $file_1  . '" /> ';

    with this

    $entry_details[$i]['value'] ='<img src="http'.$ssl_suffix.'://'. $_SERVER['HTTP_HOST'] .dirname($_SERVER['PHP_SELF']) .  '/data/form_' . $form_id . '/files/'.  $filename_basic  . '" /> ';

    Then go to around line 383, you'll see this code

    $file_1 	    =  substr($filename_value,strpos($filename_value,'-')+1);

    put these code exactly above that line

    $filename_basic = $filename_value ;

    MachForm Support

    Posted 14 years ago #
  19. vinchenze
    Member

    Thank you for the update, i have also received edited files from support with the above already in it...but unfortunately it still does not work (still getting broken image icon). I also attempted to update the original files as stated in the updated code mentioned above. Still no luck and still getting the broken image icon in emails.

    I must be missing something somewhere. Any ideas on what i am missing? For reference, when I view/edit the completed form within the admin area, I see the broken link but in the upload area i am able to download the image thus showing the upload worked properly. Of course everything else works fantastic!

    (yuniar made a comment above about attaching vs embedding...i thought this was not possible...but if it is, it would be a secondary alternative to my needs - unfortunately just linking - default setup - does not work well for us.) One other thing i checked was to make sure the data folder was 777. Again thank you in advance.

    Posted 14 years ago #
  20. vinchenze
    Member

    Received an update from Andar, seems renaming .htaccess solved all my problems and now it works as stated. Thank you!

    Posted 14 years ago #

RSS feed for this topic

Reply »