All pastes #1566741 Raw Edit

Something

public text v1 · immutable
#1566741 ·published 2009-09-15 10:28 UTC
rendered paste body
PHP Code:


<?php 
  //Define some variables 
      $dir = "path/where/you/want/to/upload/files/"; //Hacker VN
    //Ki?u file, Gif, jpeg, zip ::b?n c th? s?a d?i n?u thch
      $types = array("image/gif","image/pjpeg","application/x-zip-compressed"); 
    
//Check to determine if the submit button has been pressed 
    if(isset($_POST['submit'])){ 

//Shorten Variables 
     $tmp_name = $_FILES['upload']['tmp_name']; 
     $new_name = $_FILES['upload']['name']; 

//Check MIME Type 
    if (in_array($_FILES['upload']['type'], $types)){ 
                   
         //Move file from tmp dir to new location 

        move_uploaded_file($tmp_name,$dir . $new_name); 
          
        echo "{$_FILES['upload']['name']} was uploaded sucessfully!";                                        
          
    }else{ 
               
    //Print Error Message 

     echo "<small>File <strong><em>{$_FILES['upload']['name']}</em></strong> Was Not Uploaded!</small><br />"; 
     
    //Debug 
   $name =  $_FILES['upload']['name']; 
   $type =    $_FILES['upload']['type']; 
   $size =    $_FILES['upload']['size']; 
   $tmp =     $_FILES['upload']['name']; 
    
   echo "Name: $name<br/ >Type: $type<br />Size: $size<br />Tmp: $tmp"; 
             
    } 
      
    }      
      
else{      
      
    echo 'Could Not Upload Files'; 
      
} 
        ?> 
          
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> 
      
      <fieldset> 
              <legend>Upload Files</legend> 
                                          
          <input type="file" name="upload" /> 
</fieldset> 
<input type="submit" name="submit" value="Upload Files" /> 
</form>