Question

Actually this is about a cloud storage web app

A web app where user have their own private folder and i want they should have their own folders too .What could be the best way, to tell uploader that the file being uploaded has to be in specific folder in which user is in.

So what i thought is whenever a folder is created and opened a session which stores folder name is started and sent to uploader where Uploader that way uploads.

For eg $_SESSION['folder-name']='x'

$upload_dir= "/$_SESSION['username']/$_SESSION['folder-name']/"

Every user has specific private directory where they can upload files. So there is no chance that session can be manipulated to upload in wrong user directory.

Since now i see this way as the best way, is there any alternative i can get from stackoverflow community on this . if yes, please describe

Was it helpful?

Solution

Since your username is unique I suppose then I seems legit. But lets see this scenario:

A user get's deleted and another one registers with the same username...

EDIT

It depends on the fs and many other factors. Eg is this going to be url accessible ?

An legit alternative could be:

Since the username as you set it seems to be unique then you could first md5 it (is quick) and then digest to hex if you want it shorter and url accessible. That will give you a good number of usernames that can be converted to folders.

Bad thing about this is that you can't find the user by the folder name. If you had that in mind

That's it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top