1 0 1 n o w.com
Search Engine All- in One Place !

javascript – send uploaded file via phpmailer


I have a form, with a input files element.
I would like to select a file with this element and send it via ajax to antother php file:

** HTML **

<form enctype="multipart/form-data">
   <input type="file" id="angebote" name="angebote[]" accept=".pdf" multiple />
</form>

** Script **

var form_data = new FormData();                  
for (var index = 0; index < $('#angebote').prop('files').length; index++) {
   form_data.append("angebote[]", $('#angebote').prop('files')[index]);
}
    
$.ajax({
    url: 'ajax/sendAnforderung.php', 
    cache: false,
    contentType: false,
    processData: false,
    data: form_data,                         
    type: 'post',
    success: function(response){
        //...
    }
});

** PHP **

print_r($_FILES);

** Result **

Array
(
    [angebote] => Array
        (
            [name] => Array
                (
                    [0] => scan.pdf
                )

            [type] => Array
                (
                    [0] => application/pdf
                )

            [tmp_name] => Array
                (
                    [0] => /volume1/@tmp/phpiZrjNh
                )

            [error] => Array
                (
                    [0] => 0
                )

            [size] => Array
                (
                    [0] => 509145
                )

        )

)

Now I would like to send this file as an attachment via php mailer.
for this I nee the path of the file.

I tried this:

echo $_FILES['angebote']['tmp_name'][0]."https://stackoverflow.com/".$_FILES['angebote']['name'][0];

Result:

/volume1/@tmp/phpiZrjNh/scan.pdf

But the file is not be accessable.
Where is my mistake?



Source link
javascript,php,jquery,phpmailer

#javascript #send #uploaded #file #phpmailer

© 2023 All Rights Reserved. 101now.com ® is a free online search engine index services. 101now™ has large comprehensive directories for people all ages or any location where you can benefit and enjoy our platform. We provide up to date information and more on a daily basis.
Terms of Service | Privacy
newyorkconstructionco.com 101now.net 101now.org