Difference between revisions of "CSC220 uploadFile1.htm"
(Created page with '--~~~~ ---- __TOC__ <br /> =FileUpload1.htm= <code><pre> </pre></code> =FileUpload1.php= <code><pre> </pre></code> <br /> <br /> <br /> <br /> <br /> <br /> <br /> …') |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
<br /> | <br /> | ||
=FileUpload1.htm= | =FileUpload1.htm= | ||
+ | |||
<code><pre> | <code><pre> | ||
+ | <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> | ||
</pre></code> | </pre></code> | ||
Line 12: | Line 27: | ||
=FileUpload1.php= | =FileUpload1.php= | ||
+ | |||
<code><pre> | <code><pre> | ||
+ | <?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(); | ||
+ | |||
+ | ?> | ||
+ | |||
</pre></code> | </pre></code> | ||
+ | =Output= | ||
+ | |||
+ | FILES | ||
+ | |||
+ | Array | ||
+ | ( | ||
+ | [uploaded] => Array | ||
+ | ( | ||
+ | [name] => deleteme.txt | ||
+ | [type] => text/plain | ||
+ | [tmp_name] => /tmp/phpUujdld | ||
+ | [error] => 0 | ||
+ | [size] => 54 | ||
+ | ) | ||
+ | ) | ||
+ | |||
<br /> | <br /> |
Latest revision as of 10:13, 8 November 2010
--D. Thiebaut 15:08, 8 November 2010 (UTC)
Contents
FileUpload1.htm
<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>
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();
?>
Output
FILES Array ( [uploaded] => Array ( [name] => deleteme.txt [type] => text/plain [tmp_name] => /tmp/phpUujdld [error] => 0 [size] => 54 ) )