Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to upload odt/doc/pdf/txt files with php
    text
    copied!<p>I can't get my uploadscript to work for the fileformates pdf, doc, odt and txt. Is there a way to accept all fileformates, just with limmited maxsize on the object? Here is my script:</p> <pre><code>&lt;?php $allowedExts = array("gif", "jpeg", "jpg", "png", "doc", "odt", "pdf", "txt"); $temp = explode(".", $_FILES["file"]["name"]); $extension = end($temp); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/pjpeg") || ($_FILES["file"]["type"] == "image/x-png") || ($_FILES["file"]["type"] == "image/png") || ($_FILES["file"]["type"] == "application/pdf") || ($_FILES["file"]["type"] == "application/txt") || ($_FILES["file"]["type"] == "application/doc") || ($_FILES["file"]["type"] == "application/odt")) &amp;&amp; ($_FILES["file"]["size"] &lt; 50000) &amp;&amp; in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] &gt; 0) { echo "Feilmelding: " . $_FILES["file"]["error"] . "&lt;br&gt;"; } else { echo "Denne filen er lastet opp: " . $_FILES["file"]["name"] . "&lt;br&gt;"; echo "Type fil:: " . $_FILES["file"]["type"] . "&lt;br&gt;"; echo "Størrelse: " . ($_FILES["file"]["size"] / 1024) . " kB&lt;br&gt;"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " Filen eksisterer, bytt navn. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Filen er lagret her: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Feil Filtype"; } ?&gt; </code></pre> <p>It works for the pictures, but not the applications. Any help would be most appreciated, have a great eve</p> <p>In advance, thank you :)</p>
 

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