标签:
upload_file.php
<?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg"))) //&& ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?>
index.html
<html> <style> .btn{width:140px;height:36px;line-height:18px;font-size:18px; background:url("button_bg.jpg") no-repeat left top;color:#FFF;padding-bottom:4px} </style> <body> <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" class="btn" name="submit" value="Submit" onmouseover="this.style.backgroundPosition=‘left -36px‘" onmouseout="this.style.backgroundPosition=‘left top‘" /> </form> </body> </html>
button_bg.jpg
标签:
原文地址:http://www.cnblogs.com/manhua/p/4557243.html