File Upload Script

There should be the upload directory to upload the files.

<title>A File Upload Script</title>
if ( isset( $_FILES['fupload'] ) ) {

print "name: ".     $_FILES['fupload']['name'] ."<br />";
print "size: ".     $_FILES['fupload']['size'] ." bytes<br />";
print "temp name: ".$_FILES['fupload']['tmp_name'] ."<br />";
print "type: ".     $_FILES['fupload']['type'] ."<br />";
print "error: ".    $_FILES['fupload']['error'] ."<br />";

$source = $_FILES['fupload']['tmp_name'];
$target = "upload/".$_FILES['fupload']['name'];
move_uploaded_file( $source, $target );// or die ("Couldn't copy");
$size = getImageSize( $target );

$imgstr = "<p><img width=\"$size[0]\" height=\"$size[1]\" ";
$imgstr .= "src=\"$target\" alt=\"uploaded image\" /></p>";

print $imgstr;
<form enctype="multipart/form-data" action="<?php print $_SERVER['PHP_SELF']?>" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="102400" />
<input type="file" name="fupload" /><br/>
<input type="submit" value="upload!" />

Post to Twitter Post to Digg Post to Facebook Post to Google Buzz Send Gmail

Leave a Comment

Your email address will not be published. Required fields are marked *