attachment

K

ketulp_baroda

Hi
I am trying to upload a file using <input type="file"....>
I want to know what is the best way to store this uploaded file
Should I store it in the databse??
Or should I store the entire file on the server??
 
K

ketulp_baroda

Hi
I am trying to upload a file using <input type="file"....>
I want to know what is the best way to store this uploaded file
Should I store it in the databse??
Or should I store the entire file on the server??

If I decide to store the file on the server,then di I have to use ftp
to copy the file on the server??
 
I

Irmen de Jong

If I decide to store the file on the server,then di I have to use ftp
to copy the file on the server??

No, the actual file contents is submitted as part of the HTTP POST request.
(make sure you use method="post" and enctype="multipart/form-data" in your form).
Python's cgi module knows how to deal with it.

Where you store your file is entirely up to you and depends on what
you want to do with it.

--Irmen
 
K

ketulp_baroda

Irmen de Jong said:
No, the actual file contents is submitted as part of the HTTP POST request.
(make sure you use method="post" and enctype="multipart/form-data" in your form).
Python's cgi module knows how to deal with it.

Where you store your file is entirely up to you and depends on what
you want to do with it.

--Irmen

Hi
Thanks for your reply.
Ya the actual contents are posted along with the file.
See my application is like this:
User can submit any attachment and can view all the attachments
submitted by other users.
Attachment contents can be anything.
So where should I store the attachment 1)In database 2)In a file on
server
 
I

Irmen de Jong

User can submit any attachment and can view all the attachments
submitted by other users.
Attachment contents can be anything.
So where should I store the attachment 1)In database 2)In a file on
server

You give too little information to provide a conclusive answer.

However,

Putting stuff in a database can be complicated (BLOBs and stuff)
but usually takes care of concurrency control (i.e. accessing the
data by multiple users at the same time; everyone should only
see THEIR file(s)).

Storing stuff in the filesystem is by far the easiest. You don't
have to set up and access a database. But you DO have to make sure
that each file is uniquely named (you don't want me to overwrite
your 'curriculum.doc' now do you) and probably have to do
some concurrency control yourself.
Also you have to think of a way to identify which files belong
to which user, and make sure that user A cannot access user B's files.

--Irmen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top