Im looking for a simple code for users on my webpage to upload a .doc or .txt file to my email address. I've only found ones in CGI which i can't use and the one i tried only send it in binary code and not the actual word doc. Does anyone have a simple code that I can use?

Recommended Answers

All 3 Replies

Upload to your email address? Hmmm.

You can have the user upload any file at all, by placing a file upload element on your page.

<input type="file">

There are some optional attributes, such as ID or NAME, and SIZE (referring to the size of the textbox, not the size of the file.

The form must be properly encoded to allow files to be posted, add the enctype="multipart/form-data" key-value pair to your FORM element.

Once it's on the server, you'd use whatever server-side language you use to process the file, which could include emailing it somewhere.

I've done the coding of the basic form, (similar to above) tested it and got the email through correctly, but the file I was trying to upload didn't come with it. Do I have to put anything on the server to actually have the file come through?

Any help appreciated.

I have never used PHP before, but I think the answer lies in me learning how that works! I got a PHP script to send a file to a server. Brilliant for a beginner! But now I want to put a message from a form together with an uploaded file, and have both the form message and the file sent to an email address. I also want to restrict the size of the file being uploaded and make it only a word doc or pdf. Any advice appreciated. Thanks tgreer for the ID attributes tip.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.