Home > Backend Development > PHP Tutorial > php文件下传不成功

php文件下传不成功

WBOY
Release: 2016-06-13 13:18:20
Original
808 people have browsed it

php文件上传不成功

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->    print_r($_FILES);
    $name=date("Ymd_his_").rand(100,999).".txt";     
    $path=dirname(__FILE__)."/upload/".$name;
     $result=move_uploaded_file($_FILES["file"]["tmp_name"],$path);
    echo $result;
    if(!$result)   echo $_FILES['file']['error']."<br>";
    else echo "上传成功";
     
Copy after login


为什么$_FILES['file']['error']为0,上传失败

------解决方案--------------------
打开php错误提示看看
------解决方案--------------------
["file"]
file和表单的input的name是一致的
$path=dirname(__FILE__)."/upload/".$name;要保证目录是存在的
------解决方案--------------------
探讨

["file"]
file和表单的input的name是一致的
$path=dirname(__FILE__)."/upload/".$name;要保证目录是存在的
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