Home  >  Article  >  php教程  >  PHP最基本上传代码示例

PHP最基本上传代码示例

PHP中文网
PHP中文网Original
2016-05-25 16:58:101186browse

php代码

<html>
<head><meta charset="utf-8"></head>
<body>
	<form method="post" enctype="multipart/form-data"> 
	上传:<input type="file" name="myfile" /><input type="submit" value="上传" /> 
	</form>
</body>
</html>
<?php
if ( isset($_FILES[&#39;myfile&#39;]) ) {
	echo $_FILES[&#39;myfile&#39;][&#39;name&#39;];
	$up = move_uploaded_file($_FILES[&#39;myfile&#39;][&#39;tmp_name&#39;], &#39;uped.jpg&#39;);
	echo $up ? &#39;上传成功&#39; : &#39;上传失败&#39;;
}
?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn