Newbie question about attachment

Robin Munn rmunn at pobox.com
Thu Mar 18 20:01:40 EST 2004


ketulp_baroda at yahoo.com <ketulp_baroda at yahoo.com> wrote:
> Hi everyone,
> My application goes like this:
> User can submit any attachment and can view all the attachments
> submitted by other users. Attachment contents can be anything.
> Now I want that if the user selects to view a particular attachment
> then if the browser is able to show the attachment then it should
> display the attachment otherwise ask the user to save the attachment
> on the local drive.
> How should I go about this??

Without any knowledge of what language or what Web framework you're
using, it's impossible to give you specific answers. Since you're
posting this question to a Python newsgroup, I'll assume you're using
one of the Python Web frameworks -- if that's not the case, then another
newsgroup would be more helpful to you. If you're using PHP, for
example, you should really be asking this question in the comp.lang.php
newsgroup.

For uploading attachments, you want to look into the HMTL <INPUT
TYPE="file"> tag.

For the browser viewing attachments, you want to look into MIME types
and how to set them in your server. E.g. if the attachment is a JPG,
you'd want to set MIME type "image/jpeg". Beware of bugs in Internet
Explorer, which Microsoft *still* hasn't fixed, that cause it to ignore
MIME types in favor of file extensions!

I hope this helps. If you need more help, post a more detailed question.
Code snippets are a major plus: Saying "My code doesn't work!" is
useless to us because we can't see your code. But saying "My code
doesn't work. Here's the code, here's what I think it should do, and
here's the error message I'm getting" will get you help from several
different knowledgeable, skilled people.

-- 
Robin Munn
rmunn at pobox.com



More information about the Python-list mailing list