A File Upload: path, file name, size and type : File Upload « File Directory « PHP






A File Upload: path, file name, size and type

<html>
<head>
<title>A file upload script</title>
</head>
<?php
$file_dir = ".";
$file_url = ".";
if ( isset( $fupload ) ){
   print "path: $fupload<br>\n";
   print "name: $fupload_name<br>\n";
   print "size: $fupload_size bytes<br>\n";
    print "type: $fupload_type<p>\n\n";
   if ( $fupload_type == "image/gif" ){
     copy ( $fupload, "$file_dir/$fupload_name") or die ("Couldn't copy");
     print "<img src=\"$file_url/$fupload_name\"><p>\n\n";
   }
}
?>
<body>
<form enctype="multipart/form-data" action="<?php print $PHP_SELF?>" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="51200">
    <input type="file" name="fupload">
    <input type="submit" value="Send file!">
</form>
</body>
</html>

           
       








Related examples in the same category

1.Save Upload File to a new directory
2.Upload PDF file and rename it
3.HTML form with a file input tag
4.File Upload Global Variables