PHP Classes

File: ex_files.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  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: 9 years ago
Size: 1,350 bytes


Class file image Download
# Version 1.0

$fi = new file_handle();

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

// Set the upload directory

// 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($dir, 0777);

// 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

// Remove file from server

// Remove a directory

// 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 );