PHP Classes

File: PHP_toolbucket/SoftMoon/getUploadedFile.php

Recommend this page to a friend!
  Packages of Joseph   Rainbow Maker   PHP_toolbucket/SoftMoon/getUploadedFile.php   Download  
File: PHP_toolbucket/SoftMoon/getUploadedFile.php
Role: Auxiliary script
Content type: text/plain
Description: PHP utility function
Class: Rainbow Maker
Create transparent gradient images
Author: By
Last change:
Date: 14 years ago
Size: 858 bytes
 

 

Contents

Class file image Download
<?php

Function getUploadedFile($filefield, $index, $destination, $filetypes=FALSE, $echoIt=TRUE)  {
    if ( is_array($_FILES[$filefield])
    and $_FILES[$filefield]['error'][$index]['file']==0
    and $_FILES[$filefield]['size'][$index]['file']>128
    and $_FILES[$filefield]['tmp_name'][$index]['file']!=""
// and in_array($_FILES[$filefield]['type'][$index]['file'], array("image/png", "image/gif", "image/jpg")) //...good luck listing all possible mime types...
    and (!is_array($filetypes) or in_array(strtolower(strrchr($_FILES[$filefield]['name'][$index]['file'], ".")), $filetypes))
    and move_uploaded_file( $_FILES[$filefield]['tmp_name'][$index]['file'],
            $destination.=($UpL_name=basename($_FILES[$filefield]['name'][$index]['file'])) ) )
        {
            if ($echoIt)  echo "$filefield file: $UpL_name<br />\n";
            return $destination;
        }
    else return NULL;  }
?>