Forums

File attachment by file already existing on server

andreasuriani 10 Apr, 2019
Hi there,
I'm using Joomla 3.9 + CF5.
I'm trying to send an email post form to submit, but using a file already existing on the server (no upload file needed).

Any ideas?
I cannot able to understand how to set the setup...

I created a hidden type called "filepdf" and i need to put it in a file attachment on email settings...

Thanks in advance.

Andrea
healyhatman 10 Apr, 2019
Just put the filepath directly in the email attachment settings, right?
andreasuriani 11 Apr, 2019
Hi,
thanks for your reply.

I've tried to to this but unfortunately didn't work.

CF5 EMAIL SETTINGS: Attachment File > {filepdf} or without {}

The code in Custom:

<div class="gcore-input gcore-display-table" id="fin-filepdf"><input type="hidden" id="filepdf_ghost" data-ghost="1" value="<?php echo $filepdf; ?>" class="form-control A" name="filepdf" />
<input name="filepdf" id="filepdf" class="form-control gcore-height-auto A" title="" style="" multiple="0" data-load-state="" data-tooltip="" type="file" /></div></div>


$filepdf is the address where the file is stored.


Any ideas?
healyhatman 11 Apr, 2019
Just put the filepath directly in the attachment file setting, don't put it in a hidden input. That's a terribly stupid way of doing it, because I could press F12, replace it with a different filepath, and download any file on your server I want.
andreasuriani 11 Apr, 2019
Where exactly? I cannot see this kind of settings.
Could you kindl give me an example?
healyhatman 11 Apr, 2019
Where you put {filepdf} put a full path to your file instead
andreasuriani 11 Apr, 2019
I tried to put this > variazioni_mensili/420/20170308163609-DI GIUSTO MIRKO-MODULI SINDACATI-2017Febbraio.pdf but it'doesnt work.....

Obiuvsly, the address is correct (i mean, if i put the code in the bar address i'm able to see the document)
healyhatman 11 Apr, 2019
No it's not obvious. Needs to be a FILE PATH not a URL
andreasuriani 11 Apr, 2019
Sorry, i'm not an expert..
How can i discover the file path from the address?
If i take a look to the folder, the PATH is exactly the same.



andreasuriani 11 Apr, 2019
Hi, solved the issue in this way:

<?php

$path = JPATH_SITE.'/'.$_POST['filepdf'];
$form->files['allegato']['path'] = $path;




?>

Follow the istructions from https://www.chronoengine.com/faqs/70-chronoforms/cfv5/5224-how-can-i-attach-files-from-my-server-to-an-email-in-cfv5
Thanks
healyhatman 11 Apr, 2019
Again if you do that, you will let a person download any file they want from your server.

Just echo JPATH_SITE.'/'.$_POST['filepdf']; and that should give you thge file path you're after
healyhatman 11 Apr, 2019
OK I see my confusion. You should follow the very first piece of code on that FAQ.
andreasuriani 11 Apr, 2019
Don't worry. Thanks for your help anyway
This topic is locked and no more replies can be posted.