Login   Register  
PHP Classes
elePHPant
Icontem

File: ex_files.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Danny Tucker  >  EZ Framework  >  ex_files.php  >  Download  
File: ex_files.php
Role: Example script
Content type: text/plain
Description: Example
Class: EZ Framework
Framework providing several types of functionality
Author: By
Last change:
Date: 2006-03-05 17:10
Size: 1,350 bytes
 

Contents

Class file image Download
<?php
# Version 1.0
require_once('../include/config.inc.php');

$fi = new file_handle();

// Do NOT add an ending slash
$dir 'files/upload';

// Set the upload directory
$fi->setUploadDir($dir);

// Add ending slash so you don't have to retype it for file paths now
$dir .= '/';

// Auto Create directory if not exist
// You don't need to check if it already exsist, it does this in the function
$fi->createDir($dir0777);

// Upload a file
// (Name of file upload field, filename to save as)
$fi->uploadFile("myfile1"$newfilename)

// Rename / move a file
// You can also move files using a different directory path for the second param
$fi->renameFile($dir.$newfilename,$dir.$anotherfilename);

// Remove file from server
$fi->removeFile($dir.$anotherfilename);

// Remove a directory
$fi->removeDir('testupload/folder1');

// Get a files mime type based on the file names extension
$fi->getFileType('myfile.jpg'); // = image/jpeg

// Get a files extension, all the characters after the last period
$fi->getFileExtension('myfile.gif'// = gif

// Download a file using below method \/
// header( 'Content-type: ' . file_handle :: getFileType( $file_path ) );
// header( "Content-Disposition: attachment; filename={$file_path}" );
// readfile( $filename );
$fi->downloadFile($dir.$filename);
    
?>