Upload files when a user fills out a form

I am creating a form in which users can post an ad, including photos. To access this form, the user does not need to log in / register. I need to upload photos asynchronously when a user fills out a form. (e.g. gumtree.com.au allows you to upload photos while creating a new ad)

I know that we can start downloading files as soon as the user selects the files. However, on the server side, how can these files be identified later when the user submits the form? How to handle downloaded files if the user refuses an empty form?

What is a typical design pattern to achieve this?

+4
source share
1 answer

this is one approach

Part 1

when a user visits your site, he communicates with the server and sends randomly generated 10 alphanumeric characters, for example (Xf4ht5Y4u9). This is user id code

can be easily achieved using javascript and ajax on the client side.

on the server side, you can use PHP to create a temporary directory with the user identification code

Part 2

user uploads files and sends them asynchronously to this temporary folder

Part 3

= true - , , , temp. temp . , . ,

= false --- temp, .

4

. temp , . script

, , , . , , temp > 6 -

6 , , , , . , .

5 , , , .

+2

Source: https://habr.com/ru/post/1629088/


All Articles