


What should I do if PHP prompts that the upload root directory does not exist?
Solution to the problem when PHP prompts that the upload root directory does not exist: first grant permissions to the root directory and check whether the problem is solved; if the problem is not solved, use the mkdir command to create a new folder; finally, give the newly created folder the highest permissions.
The operating environment of this article: windows10 system, php 7, thinkpad t480 computer.
Problem restoration:
After trying to upload a picture, I got a prompt: "The upload root directory does not exist! Please try to create it manually."
Solution:
Try to give permission first, and if the problem still cannot be solved, delete the folder. Then use the mkdir command to create a new folder and give it 777 permissions.
Question 2:
I encountered the following problems during the development process of using ThinkPHP3 to upload images:
The upload root directory does not exist! Please try to create manually: ./Uploads/; the uploaded pictures have garbled Chinese names; when uploading files, a folder named after the current date will be automatically generated and the files will be saved in it.
Note: The development environment is Xampp under Windows
Attached is the code before the problem is solved:
The following are three questions Solution:
Problem 1
When checking information, some netizens said that this is a folder permission problem. It can be solved as follows:
For example, if you want to save the uploaded pictures to ./ In the Uploads directory, set rootPath to './' and savePath to the path to be saved. Be careful not to put "./" in front. The final saving directory path is ./Uploads/1/.
$upload->rootPath = "./"; $upload->savePath = "Uploads/$uid/";
Question 2
Find the save method in the ThinkPHP\Library\Think\Upload\Driver\Local.class.php file:
Change
if (!move_uploaded_file($file['tmp_name'], $filename))
to
if (!move_uploaded_file($file['tmp_name'], iconv('utf-8','gb2312',$filename)))
Question 3
When uploading, the subdirectory is automatically used to save the uploaded file by default, that is, $upload->autoSub = true; Just set it to false.
Add the following code to the upload parameters in the code:
$upload->autoSub = false;
Recommended learning: php training
The above is the detailed content of What should I do if PHP prompts that the upload root directory does not exist?. For more information, please follow other related articles on the PHP Chinese website!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


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

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 English version
Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool