XML/HTML Code
- <formid="upload"method="post"action="upload.PHP"enctype="multipart/form-data">
- divid="drop">
- DropHere
- a>Browse</a>
- inputtype="file"name="upl"multiple/>
- </div>
- ul>
- <!--Thefileuploadswillbeshownhere-->
- form>
PHP Code
- <?PHP
- //Alistofpermittedfileextensions
- $allowed=array('png','jpg','gif','zip');
- if(isset($_FILES['upl'])&&$_FILES['upl']['error']==0){
- $extension=pathinfo($_FILES['upl']['name'],PATHINFO_EXTENSION);
- if(!in_array(strtolower($extension),$allowed)){
- echo'{"status":"error"}';
- exit;
- }
- if(move_uploaded_file($_FILES['upl']['tmp_name'],'../upload/'.$_FILES['upl']['name'])){
- echo'{"status":"success"}';
- exit;
- }
- ?>