Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP file txt upload validation content
    primarykey
    data
    text
    <p>I got a php script to upload file .txt only and it works.</p> <pre><code>&lt;?php $allowedExts = array("txt"); $temp = explode(".", $_FILES["file"]["name"]); $extension = end($temp); $dest = "/etc/squid/squid.conf"; if ((($_FILES["file"]["type"] == "text/plain") &amp;&amp; ($_FILES["file"]["size"] &lt; 170000) &amp;&amp; in_array($extension, $allowedExts))) { if ($_FILES["file"]["error"] &gt; 0) { echo "Return Code: " . $_FILES["file"]["error"] . "&lt;br&gt;"; } else { echo "&lt;div style='text-align: center'&gt;"; echo "Upload File Success!!&lt;br&gt;&lt;br&gt;"; echo "FIle : " . $_FILES["file"]["name"] . "&lt;br&gt;"; echo "Type : " . $_FILES["file"]["type"] . "&lt;br&gt;"; echo "Size : " . ($_FILES["file"]["size"] / 1024) . " kB&lt;br&gt;"; echo "&lt;/div&gt;"; move_uploaded_file($_FILES["file"]["tmp_name"], "/var/www/squid_proxy/upload/" . $_FILES["file"]["name"]); copy("/var/www/squid_proxy/upload/" . $_FILES["file"]["name"], $dest); } } else { echo "&lt;div style='text-align: center'&gt;"; echo "Error, File upload only .txt"; echo "&lt;/div&gt;"; } ?&gt; </code></pre> <p>file types and mime validation is works, but i want file txt content validation. Example, txt file content must have headers</p> <p>example.txt</p> <pre><code>#ADVANCED #WIZARD </code></pre> <p>Before txt file upload to server, it must be check the file contents header, on first line should be have #ADVANCED and on the third line should have #WIZARD, if user upload txt file not have headers like that or empty/blank file it should be display error message.</p> <p>How script to check or validation the content of the file upload?</p> <p>Sorry for my bad english, thanks :)</p>
    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.
 

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