php文件上传入门级代码
这是一个新手写的上传文件,开始有点问题经过处理完全可以实现文件上传,支持任何类型.
- <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
- )
- )