Home > Backend Development > PHP Tutorial > input 上传文件

input 上传文件

WBOY
Release: 2016-06-23 14:02:35
Original
962 people have browsed it

input type=file 上传文件      把文件上传到 服务器里的image下 应该怎么写 


回复讨论(解决方案)

看看这里
http://www.w3school.com.cn/php/php_file_upload.asp

给个简单的例子吧:

<?php if($_POST['submit']){	move_uploaded_file($_FILES["file"]["tmp_name"],      "./images/" . $_FILES["file"]["name"]);      echo "Stored in: " . "images/" . $_FILES["file"]["name"];}?><html><body><form action="" method="post" enctype="multipart/form-data"><label for="file">Filename:</label><input type="file" name="file" id="file" /> <input type="submit" name="submit" value="Submit" /></form></body></html>
Copy after login

加注释的代码:

<?php if($_POST['submit']){	$url="./images/";//服务器的绝对路径目录	move_uploaded_file($_FILES["file"]["tmp_name"],      "$url" . $_FILES["file"]["name"]);//从临时目录把文件移入服务器指定目录      echo "Stored in: " . "images/" . $_FILES["file"]["name"];}?><html><body><form action="" method="post" enctype="multipart/form-data"><label for="file">Filename:</label><input type="file" name="file" id="file" /> <input type="submit" name="submit" value="Submit" /></form></body></html>
Copy after login

怎么检测是否有重复的文件呢

加注释的代码:
PHP code?123456789101112131415161718
move_uploaded_file  是否有重复的文件 不会覆盖。。

看看php上传文件。

不会。。求代码

#1 中的链接里面就有,怎么就不去看看呢

哈哈 没仔细看

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template