關於課程
<p>請選擇要上傳的檔案。</p>
<form action=”uploadoutput.php” method=”post” enctype=”multipart/form-data”>
<p><input type=”file” name=”file”></p>
<p><input type=”submit” value=”開始上傳”></p>
</form>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
<?php
if (is_uploaded_file($_FILES[‘file’][‘tmp_name’])) {
if (!file_exists(‘upload’)) {
mkdir(‘upload’);
}
$file=’upload/’.basename($_FILES[‘file’][‘name’]);
if (move_uploaded_file($_FILES[‘file’][‘tmp_name’], $file)) {
echo $file, ‘上傳成功。’;
echo ‘<p><img src=”‘, $file, ‘”></p>’;
} else {
echo ‘上傳失敗。’;
}
} else {
echo ‘請選擇檔案。’;
}
?>