PHP上传文件学习

<?php /** * @author Tody Kwok * @copyright (c) Tody, 2010 */ date_default_timezone_set('Asia/Hong_Kong'); $size=$_FILES["UPLOAD"]["size"]; $name=$_FILES["UPLOAD"]["name"]; $type=$_FILES["UPLOAD"]["type"]; $ext = strtolower(substr(strrchr($name,'.'),1)); $uploadname=date("YmdHis").".".$ext; echo "File Name: ".$name."<br>"; echo "File Size: ".$size."<br>"; echo "File Type: ".$type."<br>"; echo "Upload Name: ".$uploadname."<br>"; if (move_uploaded_file($_FILES['UPLOAD']['tmp_name'],'./'.$uploadname)) { echo 'Upload Ok'; }else { exit("Upload fail"); } ?

上面是PHP上传文件的一个例子

<form action="upload.php" method="post" enctype="multipart/form-data"> <p>File: <input type="file" name="UPLOAD" /> <input type="submit" value="Send" /> </p> </form>

用来给最上面提供本地上传的HTML文件接口

你可能感兴趣的:(PHP,Date,timezone,upload,File,action)