<html> <head> <title>File Upload Script</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </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 ); $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"> <table <tr> <td><input type="hidden" name="MAX_FILE_SIZE" value="102400" /></td> </tr> <tr> <td><input type="hidden" name="MAX_FILE_SIZE" value="102400" /></td> </tr> <tr> <td><input type="file" name="fupload" /></td> </tr> <tr> <td><input type="submit" value="upload!" /></td> </tr> </table> </form> </body> </html> |
Wednesday, 17 September 2014
File Upload Script in PHP
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment