Note that there are some explanatory texts on larger screens.

plurals
  1. POFileSize in Multiple Attachments
    primarykey
    data
    text
    <p>I am sending multiple attachments with an Email Message, Now i want to check the Extension and Size of the Attached File, For which i am using the Code:</p> <pre><code>foreach(array_keys($_FILES['attachment']['name']) as $key) { $file=$_FILES['attachment']; $filesize = (filesize($file) * .0009765625) * .0009765625; echo $filesize; if ($FileSize &gt; 100) { echo "&lt;script type='text/javascript'&gt;parent.document.getElementById('sizeerrormessage').style.display = 'inline';&lt;/script&gt;"; } $source = $_FILES['attachment']['tmp_name'][$key]; $filename = $_FILES['attachment']['name'][$key]; $mail-&gt;AddAttachment($source, $filename); } </code></pre> <p>I gives error that for calculating File Size and Extension an array is given, string required.</p> <p>For Multiple Attachments, attachment[] is an arrray.. How to check the file size and extension of an array type now The Form Code is</p> <pre><code>&lt;input type="file" name="attachment[]" id="attachment" size="30" onchange="document.getElementById('moreUploadsLink').style.display = 'block';" /&gt; &lt;div id="moreUploads"&gt;&lt;/div&gt; &lt;div id="sizeerrormessage" style="display:none;margin-left:30px"&gt; &lt;font color=#990000 size=1&gt;File exceeded maximum allowed limit of 100 Kb&lt;/font&gt; &lt;/div&gt; &lt;div id="typeerrormessage" style="display:none;margin-left:30px"&gt; &lt;font color=#990000 size=1&gt;Only png, jpg and gif are allowed extensions.&lt;/font&gt; &lt;/div&gt; &lt;div id="moreUploadsLink" style="display:none;"&gt;&lt;a href="javascript:addFileInput();"&gt;Attach another File&lt;/a&gt;&lt;/div&gt; </code></pre> <p>And the javascript is</p> <pre><code>&lt;script type="text/javascript"&gt; var upload_number = 1; var attachmentlimit = 5; function addFileInput() { var d = document.createElement("div"); var file = document.createElement("input"); file.setAttribute("type", "file"); file.setAttribute("name", "attachment[]"); /* file.setAttribute("name", "attachment"+upload_number);*/ d.appendChild(file); document.getElementById("moreUploads").appendChild(d); upload_number++; if(upload_number == attachmentlimit) { document.getElementById('moreUploadsLink').style.display='none'; } } &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload