Created
May 3, 2021 08:29
-
-
Save Tynael/7467e767ed05fe12b734f8e10db035b2 to your computer and use it in GitHub Desktop.
PHP Code Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>A File Upload Script</title> | |
</head> | |
<body> | |
<div> | |
<?php | |
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 />"; | |
if ( $_FILES['fupload']['type'] == "image/gif" ) { | |
$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; | |
} | |
} | |
?> | |
</div> | |
<form enctype="multipart/form-data" | |
action="<?php print $_SERVER['PHP_SELF']?>" method="post"> | |
<p> | |
<input type="hidden" name="MAX_FILE_SIZE" value="102400" /> | |
<input type="file" name="fupload" /><br/> | |
<input type="submit" value="upload!" /> | |
</p> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example used for: https://neutrondev.com/5-popular-programming-languages-and-their-uses/