Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to know who has uploaded files ?

Status
Not open for further replies.

newlearner2005

Programmer
May 9, 2005
32
US
Hello everybody,

I have just learned sucessfully how to uploaded and downloaded files to MySQL database. The server or clients can even view or save those files by clicking on them.
But I still got trouble. My question is:
How to know who has uploaded files ? (assume that client has registered to be a memeber of my website and I have create a new page for each member on my website )
I mean, after the client A had uploaded files sucessfully, how to see that file appearing on that clitnt A web page?
Could anybody help me?
Thank you very much in advance.
newleaner
 
I assume you have implemented some kind of security, where each client has to log in with a unique login and password. If so, then you can track that login as the user uploads the file.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thank you very much sleipnir214,

I am just a new learner of PHP. I have learned it for 3 months, so there are a lot of things I do not know.
Yes, you understand a part of my question, but actually I do not care much of security right now.
All I need to know is who has just uploaded files. Which member of my website has just uploaded ? Of course they must be members of my website. ( because I wrote the program to do that at the first of beginning)If they are not, they cannot access to my website at the first of beginning.
Could you help me how to add some PHP code in my "upload.php" file(or something else I do not know )?
Thank you so very much. I really appreciate.
new learner
 
Hello sleipnir214,

Thank you very much for your quick help. I cannot thank you enough.
I still do not understand what exactly I have to add in mytable. ( Dummy me !) OK, I have created two databases named "registration" and " my_upload" ( I am using MySQL )
In "registration" database, I created a "user_info" table very simply as follow

CREATE TABLE user_info (
username varchar(50) NOT NULL,
password varchar(255) NOT NULL,
id int(10) NOT NULL default '0',
);

In "my_upload" database, I created a "upload" table as follow:
CREATE TABLE upload (
id int NOT NULL auto_increment,
name_of_file varchar(30) NOT NULL,
type_of_file varchar(30) NOT NULL,
size_of_file int NOT NULL,
content_of_file MEDIUMBLOB NOT NULL,
PRIMARY KEY (id)
);

What exactly you suggest me to add in table and what database ?
Thank you very much. I appreciate.
newlearner
 
Again, I do not know how you are maintaining user login state from one script-run to another. You might be keeping the username in a session variable, you might be keeping the user's ID number in a cookie, or you might be passing some value around on all your forms.

First, I wouldn't keep the actual contents of the file in teh database for several reasons. I would have kept the file contents on the server's filesystem and the name of the file in the database. But be that as it may....

Second, I would have created the user_info table something like:

CREATE TABLE user_info
(
pkid int unsigned auto_increment primary key,
username varchar(50) NOT NULL,
password varchar(255) NOT NULL,
);

Then upload as something like:

CREATE TABLE upload
(
id int unsigned auto_increment primary key,
name_of_file varchar(30) NOT NULL,
type_of_file varchar(30) NOT NULL,
size_of_file int NOT NULL,
uploader int unsigned not null,
content_of_file MEDIUMBLOB NOT NULL
);

When a user logs in successfully, I would store his user ID (as matched by pkid in user_info) in a session variable. Then when he uploads a file, I could insert the data into the table, including the user's ID in the column "uploader" in the table "upload".


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thank you so much, sleipnir,

1) But how to insert the data from pkid from "user_info" table into uploader of "upload" table ?
For example pkid is 5, how "uploader" knows too get that?

2) Did you create two tables in the one database?

Thank you very much for your help. I know I am so stupid that I need to learn many things.
Thanks a lot again.

newlearner.
 
1. I cannot answer this question in specific, as I do not know how you are maintaining the user's login.

Again, I would be storing the user's ID in a session variable. I would take the value from there to insert itno "upload", not from the "user_info" table.


2. Why would I not create both tables in the same database?


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top