Home > Mobile >  How to create a folder insisde server depending on how many times user has uploaded files?
How to create a folder insisde server depending on how many times user has uploaded files?

Time:05-08

I have a form where users can send 1,2,3,...,x files to upload to server. When user uploads x files for first time, inside folder it must create a new folder with versions like version-1 when user uploads new files how can i know what is the current version to create a new folder with this new version uploaded from user.

I am trying to get something similar to image bellow.

Iam using PHP but i think it's irrelevant because it's a logical problem

example folders

CodePudding user response:

A while back I ran into a similar situation.
My solution was that I create a UUID (https://github.com/ramsey/uuid) which I will use as the new filename for move_uploaded_file().
I then created a DB table that stores the UUID, the original filename, the userId, upload date and version number and whatever else is needed.
New files (don't have the name yet in my DB) will be stored as version 1 in the table. If the file already exists, I grab the highest version number, add 1, and write a new record.

  • Related