Difference between revisions of "CSC220 uploadFile1.htm"

From dftwiki3
Jump to: navigation, search
(FileUpload1.php)
Line 46: Line 46:
 
<?php
 
<?php
  
 +
//----------------------------------------------
 
function printHtmlHead() {
 
function printHtmlHead() {
 
?>
 
?>
Line 54: Line 55:
 
       }
 
       }
  
 +
//----------------------------------------------
 
function printHtmlTail() {
 
function printHtmlTail() {
 
?>
 
?>
Line 62: Line 64:
 
}
 
}
  
 +
//----------------------------------------------
 
function displayTable( $caption, $table ) {
 
function displayTable( $caption, $table ) {
 
   printf( "<h3>%s</h3>\n", $caption );
 
   printf( "<h3>%s</h3>\n", $caption );
Line 69: Line 72:
 
}
 
}
  
 +
//----------------------------------------------
 +
//                M A I N
 +
//----------------------------------------------
 
printHtmlHead();
 
printHtmlHead();
 
displayTable( "FILES", $_FILES );
 
displayTable( "FILES", $_FILES );

Revision as of 10:12, 8 November 2010

--D. Thiebaut 15:08, 8 November 2010 (UTC)



FileUpload1.htm

Source

<html>
<body>

<form enctype ="multipart/form-data"
      action  ="uploadFile.php"
      method  ="POST">

File name: <input name="uploaded" type="file" />
  
<input type="submit" value="Upload" />

</form>

</body>
</html>

Output

FILES

Array
(
   [uploaded] => Array
       (
           [name] => deleteme.txt
           [type] => text/plain
           [tmp_name] => /tmp/phpUujdld
           [error] => 0
           [size] => 54
       )
)


FileUpload1.php

<?php

//----------------------------------------------
function printHtmlHead() {
?>
<html>
<body>

<?php
      }

//----------------------------------------------
function printHtmlTail() {
?>

</body>
</html>
<?php
}

//----------------------------------------------
function displayTable( $caption, $table ) {
  printf( "<h3>%s</h3>\n", $caption );
  echo "<pre>\n";
  print_r( $table );
  echo "</pre>\n";
}

//----------------------------------------------
//                M A I N 
//----------------------------------------------
printHtmlHead();
displayTable( "FILES", $_FILES );
printHtmlTail();

?>