1. Computing
Send to a Friend via Email

Uploading Files with PHP


4 of 6

Limit Files by Type
 if ($uploaded_type =="text/php")
 echo "No PHP files<br>";
The code above checks to be sure the user is not uploading a PHP file to your site. If they do upload a PHP file, they are given an error, and $ok is set to 0.
 if (!($uploaded_type=="image/gif")) {
 echo "You may only upload GIF files.<br>";
In our second example we only allow users to upload .gif files, and all other types are given an error before setting $ok to 0. You can use these basic examples to allow or deny any specific file types.
Related Video
Upload Videos to Google Video

©2014 About.com. All rights reserved.