php如何上传一个压缩文件?给个实例吧

WBOY
Release: 2016-06-23 14:12:46
Original
879 people have browsed it

从网上找了一个 不知道我错在了哪里 而且没有指定上传到哪里

表单部分

<form enctype="multipart/form-data" action="singleupload.php" method="post">     <input type="hidden" name="MAX_FILE_SIZE" value="2000000">     <input type=file name=upfile size=20>     <input type=submit value="上传文件"></form>
Copy after login



singleupload.php
if (move_uploaded_file($_FILES['upfile']['tmp_name'], $_FILES['upfile']['name'])) {    echo "<h2><font color=#ff0000>文件上传成功!</font></h2><br><br>"; }else {     echo "<h2><font color=#ff0000>文件上传失败!</font></h2><br><br>"; }
Copy after login


回复讨论(解决方案)

$_FILES['upfile']['name']
你要把临时文件复制到上传文件原来路径?注定复制失败。。。

$_FILES['upfile']['name']
你要把临时文件复制到上传文件原来路径?注定复制失败。。。

我不太明白几个问题,大家都说 move_uploaded_file 可以用于上传 
可是 move_uploaded_file 怎么规定文件是从哪里来,又到哪里。

服务器的路径是:D:\phpnow\htdocs\wpgc\wp-content\files
想要上传到服务器中files目录下 .. 

singleupload.php 是在files目录下吗

singleupload.php 是在files目录下吗

不是
singleupload.php 在 D:\phpnow\htdocs\wpgc\wp-content\themes\MyBlog

if (move_uploaded_file($_FILES['upfile']['tmp_name'], "../../files/" . $_FILES['upfile']['name'])) {

if (move_uploaded_file($_FILES['upfile']['tmp_name'], "../../files/" . $_FILES['upfile']['name'])) {

恩恩 成功了 非常感谢 
意思是说,点击提交的时候,文件是已经上传了的,只是上传到当前目录了,也就是临时目录。
move_uploaded_file是用于拷贝文件到想要的目录是吗 ? 

move_uploaded_file是移动
copy_uploaded_file是复制。

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