I have an email attachment form that is working fine when the <form action="processingtheformfile.php"> is sent to another PHP file to process.
However, when I try to implement the same idea to a form that is simply <form action="<?php echo $_SERVER['PHP_SELF']; ?>"> and then use a
if(isset($_POST['submit'])) {
$tmp_name = $_FILES['filename']['tmp_name'];
$type = $_FILES['filename']['type'];
$name = $_FILES['filename']['name'];
$size = $_FILES['filename']['size'];
before the HTML of file, the attachment ends up being noname.txt everytime, regardless of file type.
Is this because the $_FILES cannot work on a <?php echo $_SERVER['PHP_SELF']; ?> action, or should I look elsewhere for my dilemna?
Pray this makes sense….
Forms that are used for uploading files need to have
enctype="multipart/form-data"to make it work. Here’s an example:Although you report that the first form works properly, I’m not sure it works reliably in all cases. Make sure it has this value for
enctypeso it’ll work properly.