PHP Classes
Icontem

File: testUploader.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Lennart Groetzbach  >  Uploader  >  testUploader.php  
File: testUploader.php
Role: Example script
Content type: text/plain
Description: example
Class: Uploader
Class for handling file uploads
 

Contents

Class file image Download
<html>
<body>
<?php
////////////////////////////////////////////////////////////////////////

require "Uploader.php";

////////////////////////////////////////////////////////////////////////
function dumpAssociativeArray($array) {
    
$res '';
    
$header false;
    if (
is_array($array) && sizeof($array)) {
        
$res .= "<table border=1>\n";
        foreach(@
$array as $values) {
            if (!
$header) {
                
$res .= "<th>" implode("</th><th>"array_keys($values)) . "</th>\n";
                
$header true;
            }
            
$res .= "<tr>\n";
            foreach(
$values as $key => $value) {
                
$res .= "<td>" . ($value != '' $value "&nbsp;") . "</td>";
            }
            
$res .= "</tr>\n";
        }
        
$res .= "</table>\n";
    }
    return 
$res;
}

////////////////////////////////////////////////////////////////////////
// show debug information
echo nl2br(Uploader::debug()) . "<br>";

// only images
$allowedTypes = array("image/bmp","image/gif","image/pjpeg","image/jpeg","image/x-png");
$uploadPath 'c:/temp';
$overwrite true;

$up = new Uploader();
    if (
$up->wasSubmitted()) {
    
// files were submitted
    
echo dumpAssociativeArray($up->uploadTo($uploadPath$overwrite$allowedTypes));
// display form
} else {
    echo 
$up->openForm(basename(__FILE__)). "\n";
    echo 
$up->fileField(). "<br>\n";
    echo 
$up->fileField(). "<br>\n";
    echo 
$up->closeForm();
    
}
// display error
echo "<br>\n" nl2br($up->error);

////////////////////////////////////////////////////////////////////////

?>
</body>
</html>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products