A
A
antonio02262017-12-03 14:18:59
Database design
antonio0226, 2017-12-03 14:18:59

How to transfer files from the form to send to the mail?

Hi all.
There is a form in which files are uploaded

<div class="input-form-wrapper">
                                <span>*****</span>
                                <div class="file-upload" data-text="Выберите файл">
                                    <input type="file" name="photo_file" >
                                </div>
                            </div>

                            <div class="input-form-wrapper">
                                <span>*****</span>
                                <div class="file-upload" data-text="Выберите файл">
                                    <input type="file" name="photo_file" >
                                </div>
                            </div>

                            <div class="input-form-wrapper">
                                <span>*****</span>
                                <div class="file-upload" data-text="Выберите файл">
                                    <input type="file" name="photo_file" >
                                </div>
                            </div>

you need to send these files by mail.
I want to do it through PHPmailer
$mail->setFrom('[email protected]', 'First Last');
    $mail->addAddress('[email protected]', 'John Doe');
    $mail->Subject = 'PHPMailer file sender';
    $mail->msgHTML("My message body");
        // Attach uploaded files
    $mail->addAttachment($filename1);
    $mail->addAttachment($filename2);
    $r = $mail->send();

How can I pass files to the script?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Fedorov, 2019-09-18
@NiKusA

For such a task, the Fowler pattern Class Table Inheritance is well suited , the task of which is to make some kind of inheritance in database tables.
A certain entity Client is created, and the entities of a Legal Person and an Individual are inherited from it, they are connected 1 to 1, that is, there is either one individual or one legal entity per 1 client, this is resolved by some kind of mapping through a conditional field typein the client table, you just need to observe the moment so that the id of an individual does not intersect with a legal entity, for example, using uuid or creating an id in any other way, for example, through auto-increment of the client table.
If you implement the backend in PHP, then ORM Doctrine can work with the following structure out of the box: Documentation.

D
Dmitry, 2017-12-03
@slo_nik

Good afternoon.
Everything is described in the official documentation .

A
Arman, 2017-12-03
@Arik

What's wrong with the documentation? php.net/manual/ru/features.file-upload.post-method.php
The main thing is not to forget enctype="multipart/form-data" add

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question