PDA

View Full Version : Help in adding a Browse button



howd
04-28-2005, 07:42 PM
By chance does anyone know a code to add to a form where I can have people attach a pic or doc to it??? I found one but I cant get it to work???? Please help

<FORM action="mailto:howdmbhp@yahoo.com">
Name: <INPUT name="Name" value="" size="35"><BR>
Email: <INPUT name="Email" value="" size="35"><BR>
Address: <INPUT name="Address" value="" size="35"><BR>
Phone: <INPUT name="Phonel" value="" size="35"><BR>
<FORM METHOD="post" ACTION="mailto:howdmbhp@yahoo.com" ENCTYPE="multipart/form-data">
Attachment: <INPUT TYPE="file" NAME="attachedfile" MAXLENGTH=99 ALLOW="text/*" >
<INPUT TYPE="submit">
</FORM>

Thank you =)

mwinter
04-28-2005, 09:32 PM
There are a few issues with the markup you posted. One is relatively minor. The others are not.


<FORM action="mailto:howdmbhp@yahoo.com">The use of mailto URLs in forms is notoriously unreliable. In order for them to work, two requirements must be met:


The user needs to have configured a default mail client, capable of delivering messages to an SMTP server.
The user needs to have configured their user agent to associate mailto URLs with the mail client.
Neither of these is a given. I know someone who would be incapable of fulfilling the first as his ISP uses some awful Flash-driven mail system. It's not an application, so it can't be associated with any actions. Similarly, what of people who use Hotmail, or other Web-based systems?

No. Never use mailto URLs with forms. I'll suggest what is about the only reliable alternative in a moment.


<FORM METHOD="post" ACTION="mailto:howdmbhp@yahoo.com" ENCTYPE="multipart/form-data">You cannot nest form elements. It is forbidden, and how any particular user agent handles this situation is undefined. It might do what you want, but it probably won't.


<INPUT TYPE="file" [...] ALLOW="text/*" >Two things here.


There's no such thing as an allow attribute on input elements. Anywhere in HTML, in fact. However, there is an accept attribute which can contain a comma-separated list of media types.
If you want someone to upload images or documents (and I suppose you mean MS Word), limiting the media type to subsets of text is not the way to go about it. Images have their own type (image), and proprietary word processor formats will almost certainly be application types. I'm not sure if user agents actually use this attribute, but you'd have problems if they do. In other words: don't use it here.
So, what is the alternative? A form processor hosted on a server. A user could send a message and upload any data to a server. The server can then construct an e-mail and send it to your address. There are lots of free, remotely-hosted form mail services (http://cgi.resourceindex.com/Remotely_Hosted/Form_Processing/), and some of them do support file uploads. If you have problems once you've selected a service, you'd be better off asking that particular provider. However, feel free to ask general questions here.

Hope that helps,
Mike

howd
04-29-2005, 12:12 AM
Thank you very much for all your help. I'll check it out and try it. Again Thank you. Tiffaney =)