PX : code

File Uploader Function by Francisco Charrua
Rating: 5.00
Download this code


<?php
function upload_file($input_name$path)
         {
         global 
$HTTP_POST_FILES;
                          
         if(isset(
$HTTP_POST_FILES) && is_uploaded_file($HTTP_POST_FILES[$input_name]["tmp_name"]))
           {
           
$file_name $HTTP_POST_FILES[$input_name]["name"];   
           
           
//For those who have policies about the file types that can be uploaded
           //to their sites, $file_name can be modified to disable unwanted behaviour
           //like the serving of unwanted content.
           
move_uploaded_file($HTTP_POST_FILES[$input_name]["tmp_name"], 
                              
$path "/" $file_name);
                              
           
//I do this because some servers will set the permissions on uploaded files
           //to 0600 or 0700.  That makes recently uploaded images unviewable.
           
chmod($path $file_name0644);
           }
         }
?>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.