php文件上传的问题
php 上传文件 没有生成文件和目录
我用php写了一个简单的文件上传的页面,显示上传成功了,但(1)、对应目录下却没有上传的文件【tmp目录下没有文件,也没有生成upload目录和文件】。
(2)、move_uploaded_file的参数顺序,代码中上一行的为错误的,下一行正确,与教材上的相反。
求大神解惑。
upload.html
<form action = "upload_file.php" method = "post" enctype = "multipart/form-data"><label for = "file">Filename</label><input type = "file" name = "file" id = "file"/><br><input type = "submit" name = "submit" value = "上传"/></form>
upload.php
<?phpif($_FILES["file"]["error"] > 0){ echo "Error : ".$_FILES["file"]["error"]."<br>";}else{ echo "Upload: ".$_FILES["file"]["name"]."<br>"; echo "Type: ". $_FILES["file"]["type"]."<br>"; echo "Size: ".($_FILES["file"]["size"]/1024)."KB<br>"; echo "Stored in: ".$_FILES["file"]["tmp_name"]."<br>"; if(file_exists("upload/".$_FILES["file"]["name"])) { echo $_FILES["file"]["name"]." already exists."; } else { //move_uploaded_file($_FILES["file"]["tmp_name"], "upload/".$_FILES["file"]["name"]);// 报错 move_uploaded_file("upload/".$_FILES["file"]["name"],$_FILES["file"]["tmp_name"]); echo "<br><br><br> Storeed in: "."upload/".$_FILES["file"]["name"]; } }?>
运行结果:
Upload: d.txt
Type: text/plain
Size: 2.439453125KB
Stored in: E:\wamp\tmp\php4A7.tmp
Storeed in: upload/d.txt
回复讨论(解决方案)
大神速来救我~~~~~~~~~~~~~~~~~~~~·
用上一句报什么错
move_uploaded_file会返回一个值的。看这个方法是否执行成功。
路径存在?
写入权限?
用上一句报什么错
Warning: move_uploaded_file(upload/d.txt) [function.move-uploaded-file]: failed to open stream: No such file or directory
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'E:\wamp\tmp\php4D5.tmp' to 'upload/d.txt'
move_uploaded_file会返回一个值的。看这个方法是否执行成功。
路径存在?
写入权限?
我试了一下,返回值为false
当前目录下没有upload目录? 先创建应该就可以了。
当前目录下没有upload目录? 先创建应该就可以了。
感谢各位,我在当前目录下建了upload目录(先前建错了,建成了uploaded),并运行上一句,结果正确运行。
move_uploaded_file会返回一个值的。看这个方法是否执行成功。
路径存在?
写入权限?
建了目录后,运行正确,多谢。
当前目录下没有upload目录? 先创建应该就可以了。
但是E:\wamp\tmp\ 目录下仍没有生成相应临时文件。
当前目录下没有upload目录? 先创建应该就可以了。
但是E:\wamp\tmp\ 目录下仍没有生成相应临时文件。
要看配置。看配置在哪个目录。phpinfo

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Alipay PHP...

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...
