I'm using a Windows 8.1 system with Expressons Web 4, MySql, IE 11 and PHP 5.6.5. I.m using the following code which is from a tutorial:
<form action="upload.php" method="post" enctype="multipart/form-data" >
<input type="text" name="testtext" />
<br/>
Select image to upload:
<input type='hidden' name='maxfilesize' value='2000000'/>
<input type="file" name="filename" id="fileToUpload" />
<input type="submit" value="UploadImage" name="submit" />
</form>
and this feeds upload.php:
<?
echo '$_POST: ';
var_dump($_POST);
echo '<br/> $_FILES: ';
var_dump($_FILES);
echo '<br/> Target_Directory: ';
$target_dir = "../Home/";
echo $target_dir . '<br/>' ;
echo basename($_FILES["filename"]["name"]) . '<br/>';
$target_file = $target_dir . basename($_FILES["filename"]["name"]);
echo $target_file . '<br/>' ;
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
echo $imageFileType . '<br/>' ;
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["filename"]["tmp_name"]);
if($check !== false) {
echo "File is an image - " . $check["mime"] . ".";
$uploadOk = 1;
}
else {
echo "File is not an image.";
$uploadOk = 0;
}
}
The $_POST and $_FILES arrays show as empty no matter what I try to upload. Even a 10K .png file. If I comment out the input with type = 'file', the $_POST array will be filled with the data from the first input. If I leave it in, both arrays are empty no matter what I do.
My php.ini file has the following settings:
- file_upload = On
- upload_max_filesize = 4M
- max_file_uploads = 20
- post_max_size = 16M
I went through a 12 point check that is presented in another example but didn't see anything that was out of the ordinary. I've review at least 50 other suggestions and haven't found anything that would resolve this. It's probably something I'm overlooking but can't seem to find it.
No errors are posted in the log files relating to this problem. They do work because other errors have shown in them.
Output showing both arrays empty:
$_POST: array(0) { }
$_FILES: array(0) { }
Target_Directory: ../Home/
Notice: Undefined index: filename in C:\Users\EE\My Web Sites\timetubes\Home\upload.php on line 30
Notice: Undefined index: filename in C:\Users\EE\My Web Sites\timetubes\Home\upload.php on line 31 ../Home/
output with encoding type removed(enctype="multipart/form-data" removed from the form tag to demonstrate that pages do pass variables without the enctype):
$_POST: array(4) { ["testtext"]=> string(4) "test" ["maxfilesize"]=> string(7) "2000000" ["fileToUpload"]=> string(71) "C:\Users\EE\My Web Sites\timetubes\images\skins\medieval\tube-ghost.png" ["submit"]=> string(11) "UploadImage" }
$_FILES: array(0) { }
Target_Directory: ../Home/
Notice: Undefined index: filename in C:\Users\EE\My Web Sites\timetubes\Home\upload.php on line 30
Notice: Undefined index: filename in C:\Users\EE\My Web Sites\timetubes\Home\upload.php on line 31 ../Home/
Any help is appreciated!