mercredi 15 avril 2015

PHP Contact form - $_FILES['tmp_name'] not returning the name

I am trying to create a simple PHP Contact form using PHPMailer (because I also want to attach files through the form). And somehow something that should be really simple managed to give me headaches.


Here are some lines of code:



<form method="POST" action="" enctype= multipart/form-data">
.....
<input type="file" name="file">
</form>
.....
$file = $_POST['file']['tmp_name'];
echo $file;


My main problem is that I attach a file, complete all the fields, submit the form. I receive the email except the file attached. I tracked down and found out that, if I echo the $file var, It will display the first letter of the file. Ex: if the file is named test.jpg, echoing $file will result in a t.


I have no idea what is this happening, judging the fact that there aren't too many lines of code and nothing that will change the filename..


Hope someone can help me out.


Aucun commentaire:

Enregistrer un commentaire