這是一個新手寫的上傳文件,開始有點問題經過處理完全可以實現文件上傳,支持任何類型。
<form action="form.php教程" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="100000000">
<input type="file" name="spic"> <br>
<input type="submit" name="sub" value="upload file"><br>
<?php
if(is_uploaded_file($_FILES['spic']['tmp_name'])){
echo "<pre>";
print_r($_FILES);
move_uploaded_file($_FILES['spic']['tmp_name'],$_FILES['spic']['name']);
echo "上傳成功";
echo "</pre>";
}
?>
</form>
運行過程,隨便找個文件,顯示如下:
Array
(
[spic] => Array
(
[name] => IMG_0044.JPG
[type] => image/jpeg
[tmp_name] => F:TempphpF695.tmp
[error] => 0
[size] => 3737804
))