amir k asked:
I have a website that users with login information can upload their files. I want only the user who uploaded the file can have access to that file. I’m using PHP.
I have a website that users with login information can upload their files. I want only the user who uploaded the file can have access to that file. I’m using PHP.


2 Comments to 'PHP: How can i personalize the uploaded files by users on my website?'
March 3, 2010
Without knowing the structure of your website it is difficult to comment on this however I will assume that your users have their Username / Password and associated attributes including a User ID stored in a SQL DB.
The easiest approach here would be to simply store the uploaded content within the DB as a blob, instead of writing directly to your hosting space. This record can then be associated with the user id and you simply need to write your SQL query on the “download” page to match (Ie. SELECT `file` from `useruploads` WHERE `userid` = ‘userid’).
Trying to work this based on files that are in fact stored directly on the server is a little more difficult. A common approach is to prefix the filename with the username or user ID.
March 3, 2010
I prefer moving the folder where you store you users data out side the htdocs/ or public_html/ folder. Put the folder inside your home directory for example. and create a PHP page that calls file from inside that directory based on the userID.
Leave a comment