php上传文件

代码清单一:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GBK"> <title>文件上传</title> </head> <body> <form action="php-09.php" name="myForm" method="post" enctype="multipart/form-data"> 选择上传文件:<input type="file" name="myFile" value=""/> <input type="submit" name="submit" value="上传"/> </form> </body> </html>

 

 

代码清单二:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GBK"> <title>文件上传</title> </head> <body> <?php $name = $_FILES ['myFile'] ['name']; $type = $_FILES ['myFile'] ['type']; $size = $_FILES ['myFile'] ['size']; $error = $_FILES ['myFile'] ['error']; $temp = $_FILES ['myFile'] ['tmp_name']; if($error>0){ echo "文件上传错误!"; exit(); } //if($type!='image/gif'){ // echo "文件类型错误!"; // exit(); //} if(is_uploaded_file($temp)){ if(!move_uploaded_file($temp,'./upload/'.$name)){ echo "文件移动失败!"; exit(); } }else{ echo '文件$name'.'可能未被上传!' ; exit(); } echo "<mce:script type="text/javascript"><!-- ", "alert('提示信息:文件上传成功!')", " // --></mce:script>"; ?> </body> </html>

 

 

 

你可能感兴趣的:(html,PHP,File,input,action)