I've been trying to use the attachment scripts at http://uk2.php.net/mail to email msword files that have been uploaded to the server and I can't for the life of me get the attachment script to work. Has anyone managed to get a PHP mail script to work that attaches files or more specifically msword files?
I have the same question going, What i have ended up doing is 2 forms, a simple script for a form and then if they want to send documents, a simple script for uploads. The script for uploading is like this, simple htm <form enctype="multipart/form-data" action="uploader.php" method="POST"> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Send Your File" /> </form> PHP: and on the other page <?php // Where the file is going to be placed $target_path = "uploads/"; /* Add the original filename to our target path. Result is "uploads/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); // This is how we will get the temporary file... $_FILES['uploadedfile']['tmp_name']; $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been sent to me, and will appear on the website soon. <a href='index.php'>Click here</a> to go back to the home page, or <a href='send_your_stuff.php'>click here</a> to send more stuff<br><br> If you have any problems, please email me at <a href='mailto:jokes@onlyican.com'>jokes@onlyican.com</a>"; } else{ echo "There was an error uploading the file, please <a href='send_your_stuff.php'>click here</a> to go back and try again or email me the file at <a href='mailto:jokes@onlyican.com'>jokes@onlyican.com</a>"; } ?> PHP: You also need to change the folder setting to 777, which you should be able to do with your ftp program, if you find a way to have the form sent and the document sent in one form, please post here or email me at
Nah this is a different question. I have managed to upload my files to the server ok through the html form but I want to use the mail("example@domain.com", $subject, $message, $headers); function to actually send the uploaded file to an email address.
Thats what i wanted. I wanted someone to comeplete a form, name ect, with an option for a file, then when they send the form, i would get an email with the details the completed and the file, jpg, mov, pps ect. I could not find this, I don't know much php, but hey, next month is a new, year.
I tell you a really good find, if you want files uploaded, with little work, then a good directory lister is located at http://evoluted.net/
uploading files isn't a problem. Due to some server settings I had to figure out 3 ways of uploading files lol I have a question for the PHP gurus though; Which method is better for uploading files copy() or move_uploaded_files() ? I found copy() the cleanest looking but perhaps it's not the best performance method.
The move_uploaded_file() only handles the files that is uploaded to the server. You can use copy() on every file on the system.
I normally use move_uploaded_file() when i handle uploaded files, because of the error handling, and copy() the other times.