PHP ~ File Upload

HTML Code
<form method="post" action="action/new_filedownload.php" enctype="multipart/form-data" >
<input type="file" name="file">
<input type="submit" value="upload" />
</form>


PHP Code
$tmp = $_FILES["file"]["tmp_name"];
$name = $_FILES["file"]["name"];
copy($tmp,'filedownload/'.$name]);


get File extension
$xx = explode(".",$name);
$last = count($xx) - 1;
$fileExtension = $xx[$last];

沒有留言:

發佈留言