I have a problem that i just quite do not understand at all. I have this uploading script that always return Notice: Undefined index: uploadPDF in xxxxx
I've made sure that the form has the enctype="multipart/form-data" <form action="" method="POST" enctype="multipart/form-data">
The field also has the same name that i ask for in the code <input name="uploadPDF" size="100" type="file" title=""/>
When i try to echo $_POST['uploadPDF']
i actually get the filename in question. But when i try to var_dump the following $_FILES['uploadPDF']['name']
i get the undefined index error.
I really cant see what the problems is. I'm running on a inhouse IIS server.
Debug information:
This is the "debug" i try to do:
echo $_POST['uploadPDF']."<br />";
$filename = $_FILES['uploadPDF']['name'];
var_dump($filename);
echo "<br />";
var_dump($_FILES);
This is the output i get:
TEST PDF PORTAL V3.pdf
Notice: Undefined index: uploadPDF in C:\inetpub\myfolder\V4\admin\addRoutine.php on line 29
NULL
array(0) { }
When you upload file, you should use $_FILES['file_name']
not $_POST['file_name']
that is because, the file information is stored in the $_FILES
arrays, since you have named your input type to 'file'
So, I would suggest
Changing
echo $_POST['uploadPDF'];
to
echo $_FILES['uploadPDF'];
You better write it like this:
echo $_POST['uploadPDF']."<br />";
$filename = $_FILES['uploadPDF']['name'];
echo var_dump($filename)."<br />";
Your form as you wrote it has no action specified.
( <form action="" method="POST" enctype="multipart/form-data"> )
You need the asign "path_to_yourform.php" as your form action.
Well, this is quite embarrassing, one of the other guys working on this had left a <form action="" method="post">
in one of the included files in the project. Since this form tag was before my form tag $_FILES did not catch the index because of the missing enctype in the first form tag!