Quantcast
Channel: WordPress.org Forums » [Contact Form 7] Support
Viewing all articles
Browse latest Browse all 49500

Vinze on "[Plugin: Contact Form 7] Automatically add all files as attachments"

$
0
0

Is it possible to automatically add all the uploaded files as attachments? Now I have to add some input fields, and for each input I need to add [file-1][file-2](...) in the admin panel.

Wouldn't it be easier and more user friendly to take the $_FILES array and add each file as an attachment?

For example, see the following form:

<form action="" method="post" enctype="multipart/form-data">
	<p><input type="file" name="files[]"></p>
	<p><input type="file" name="files[]"></p>
	<p><input type="file" name="files[]"></p>
	<p><input type="submit" value="Upload files"></p>
</form>

When submitted, it will contain the following $_FILES array:

Array
(
    [files] => Array
        (
            [name] => Array
                (
                    [0] => IMG_0274.JPG
                    [1] => 100_0086.JPG
                    [2] => IMG088.JPG
                    [3] => IMAG0122.jpg
                )

            [type] => Array
                (
                    [0] => image/jpeg
                    [1] => image/jpeg
                    [2] => image/jpeg
                    [3] => image/jpeg
                )

            [tmp_name] => Array
                (
                    [0] => /tmp/phpePA1VN
                    [1] => /tmp/php3f5HBn
                    [2] => /tmp/php0SzVhX
                    [3] => /tmp/php13JaYw
                )

            [error] => Array
                (
                    [0] => 0
                    [1] => 0
                    [2] => 0
                    [3] => 0
                )

            [size] => Array
                (
                    [0] => 1815505
                    [1] => 1327656
                    [2] => 34432
                    [3] => 442358
                )

        )

)

Now the plugin needs to loop over the array, and add each attachment.

This way the end-users don't have to remember to add [file-1][file-2](...) in the admin panel. And it's possible to dynamically add unlimited file inputs.

I tried modifying the plugin myself, but I couldn't get it to work.

http://wordpress.org/plugins/contact-form-7/


Viewing all articles
Browse latest Browse all 49500

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>