這款文件上傳代碼是一個超級簡單的上傳代碼,也是沒進行過任何安全處理,這款php文件上傳代碼只適合學習使用哦
代碼如下
復制代碼
header("content-type: text/html; charset=utf-8");
?>
<form method="post" action="./uploadaction.php" enctype="multipart/form-data" name="form">
<input type="file" name="upfile" id="myfile" />
<input type="submit" name="submit" value="上傳" />
</form>
//uploadaction.php
<?php
代碼如下
復制代碼
header("content-type:text/html; charset=utf-8");
if(!empty($_files))
{
$date= date("ymdhis",time());
$fileinfo=$_files['upfile'];
foreach($_files['upfile'] as $name=>$value)
echo $name.'='.$value.'<br>';
$filesavename='./file/'.$date.$fileinfo['name'];
move_uploaded_file($fileinfo['tmp_name'],$filesavename);
echo $fileinfo['tmp_name'].'<br>';
echo "上傳成功<br>";
echo "文件位置: $filesavename";
}