A web resource is a "point" in the information space of the World Wide Web. The information displayed on it is usually presented statically, and the visitor views it. You can specify a link to a document or other resource and the visitor will download a file with information or follow the link.
Simple tools are used to transfer information to or from a server. But their reasonable use and convenient usage logic is not so simple when it comes to organizing safe, stable and reliable data processing.
File upload
There is a simple idea: there is upload and download. The first is to send the file to the server, the second is to receive it. To implement the first task, information can simply be displayed in the browser, in a window on the page, or provide a link to an information resource. To implement the second task, it is enough to write a file upload form and code for its processing on the server.

In this example (1) - two options for a link (without using PHP) to download files from the server, (2) - a form for transferring files to the server. Here the use of PHP is fundamental. Uses more progressive boot logic than usual.
In the general case, it is enough to write the above form in the page code and provide for the processing of the $_FILES array.

Checking the file name (scCheckFileName function) is not a prerequisite, but for safety and reliability it is advisable to do so. Defining rules for any uploaded file is the key to reliable operation of the web resource and respect for it from the visitor.
Logic of uploading to the server
Hosting hosting is different, but using Russian letters and some symbols in file names is fraught with danger. It can "write" the file, but then "can't" read or delete it. To avoid uncertainties, it is better to immediately rename the file and save it under a name that any hosting will adequately refer to.
In this context, uploading files to the server: PHP + MySQL. The language is used to load the file. Through the database, an association is established between the real file name and a unique one, which is formed automatically. The simplest solution, how to get its MD5 code from the real name of a file, is a unique sequence of 32 bytes. By uploading files to the server, PHP is "turned on" on the server via AJAX.

Here, the scfCheckFile() function encodes the real file name, generates a unique MD5 code from it, and starts the data transfer mechanism via AJAX. At this moment, the server does not download the file, but only checks for its presence by a unique code. If no such file is found, a new file name is formed, and an entry about the beginning of the download is placed in the table row.
The scfGetFile() function confirms that a file has been downloaded and ensures that the file record is updated.
As a result: the file is loaded, the record in the table is formed. Uploading files to the server in PHP & AJAX using JavaScript is a good and reliable solution.
AJAX mechanism for uploading files
The start of AJAX data transfer is initiated by the InitXML() function. Upload files to the server in PHP, JavaScript and AJAX using the proposed code - safely and securely.

Receiving a response from the server is performed by the WaitReplySC() function. At the bottom right, there are codes for two situations: checking for the presence of a file before uploading and the actual upload procedure.

Coding options may be different, the essential thing is that the file upload button is not active until it is selected and verified by the server.

Server code in PHP
The server should check if the file can be loaded. Obstacles to downloading are determined by the task being solved, but it is always important not to overwrite information, that is, to provide for and block the uploading of files to the serverin PHP again.
To solve this problem, the easiest way is to create a table in the MySQL database and mark the loading of each file with one line. Here you can store the real name of the file, its extension, upload date, keep a record of operations on it, etc.

This is the code to check if a file exists by its unique name. The $oBase NewViuq() database object function determines a unique name for the element being loaded and maps it to the actual filename.

If the name validation was successful, the visitor clicks on the download button and the AJAX mechanism initiates the upload of the files to the server. The PHP code corrects the entry in the MySQL table and produces the following result:

Another element has appeared in the file system, and the table row of this file has received the final content. The status field (f_status) contains the symbol "N", that is, there have been no operations on the uploaded file yet.
Data exchange logic
The ubiquity of docx,.xlsx,.pdf files and archives has led to the formation of a not entirely correct concept: HTML & PHP downloading files from the server is a link to them. However, it is not necessary that the visitor downloads the element. Often a programmer simply opens the file in a browser for viewing.
Many tasks involve changing the information in these files. A company employee who administers the site checks a set of up-to-date files, downloadsthem, modifies them and sends them back to the server. Such logic causes significant traffic, loads communication channels and makes both maintaining the web resource and working with it time-consuming.
Of course, it is impossible to change the existing system of information relations in a particular company. If priority is given to the file organization, then it should be optimized. If it is possible to transform files into data and work with them directly, then the ideal option would be: uploading, converting them into an active form that allows changing the content by its elements. When a file needs to be downloaded from the server, it is converted in the current updated state and sent to the consumer.