Home > Article > PHP Framework > 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.
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:
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.
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;
#Then define the path to read the image, assign it to the page output, and splice the database path to output the image.
The image path output you made by yourself. If the image is not displayed, it is not uploaded. The effect is as follows:
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.
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!