fastadmin custom excel file import, realize the file upload function -- has been realized

This article will introduce how the fastadmin framework can customize the import of excel files


foreword

First of all, you need to learn the framework of tp5 and understand some basic grammar formats


1. Method 1

To submit an event with a native form form, you also need to use a tp5 request controller

Disadvantage: The event will be called twice, and the file cannot be found at the second time

Advantages: simple, easy 

Note: enctype="multipart/form-data" ------- essential for file upload

                  publicitys/publics/save_import ------- file name/file name/function name (find it from the controller by default) 

2. Method 2

It is also a native form, but it is submitted using ajax

 

Advantages: safe, will not call the function twice

Note: The id name of the form tag and input tag ----- don't confuse it with others

                     new Formdate ----- Write the obtained form form in brackets

                     processData ----- Prohibit the browser from modifying your data


Summarize

All of the above methods can be implemented, but there is a simpler method

: Find other people's repackaged events or find other people's imports and copy them, and use them with a little modification

 

Advantages: safe, fast, beautiful

Note: yes

When uploading, only display specific file suffix types

Represents the event position called when uploading

Represents the style displayed before uploading

Indicates whether to upload multiple images when uploading

Here I leave it to everyone to slowly explore and improve the technology by themselves! ! !

Guess you like

Origin blog.csdn.net/m0_72196169/article/details/131570527