Home > PHP Framework > ThinkPHP > body text

How to upload pictures in thinkphp5

爱喝马黛茶的安东尼
Release: 2019-08-23 13:48:13
Original
4476 people have browsed it

How to upload pictures in thinkphp5

The front-end and back-end codes correspond to each other. The front-end code name corresponds to the background value, and the information that needs to be uploaded is obtained.

How to upload pictures in thinkphp5

The upload process is very simple. Receive the uploaded information, use the move method to transfer the data to the specified location, and then call back after success. Pay attention to the steps:

How to upload pictures in thinkphp5

Related recommendations: "ThinkPHP Tutorial"

Upload your own encapsulation, receive the passed name value, and then obtain the information to delete the image. , just query the corresponding location in the database, delete it without skipping if there is one, and then upload the image to the specified location, and that's it.

How to upload pictures in thinkphp5

The document has some method information about the image path. You can get the path and save it to the specified location in the database. It supports custom folders. If there is no folder method, it will be automatically created;

How to upload pictures in thinkphp5

#Then define the path to read the image, assign it to the page output, and splice the database path to output the image.

How to upload pictures in thinkphp5

The image path output you made by yourself. If the image is not displayed, it is not uploaded. The effect is as follows:

How to upload pictures in thinkphp5

Multiple images The upload method is determined by a name group, which is passed into the method to traverse and upload the file information; this method does not have a fixed name value and cannot be classified into different folders.

In the future, there will be opportunities to encapsulate some methods that can accept multiple name values.

How to upload pictures in thinkphp5

The above is the detailed content of How to upload pictures in thinkphp5. For more information, please follow other related articles on the PHP Chinese website!

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