I am using xampp on Windows 7. My problem is that the image isn't appearing when I clicked the submit button.
Here's my php code:
<?php
$fileLocation = 'C:\xampp\htdocs\images';
$name = $_FILES["file"]["name"];
$tempName = $_FILES["file"]["tmp_name"];
$size = $_FILES["file"]["size"];
$fileType = $_FILES["file"]["type"];
if ($fileType == "images/jpeg" && $size < 2000000)
{
if ($_FILES['file']['error'] > 0)
{
echo "File error! : " . $_FILES['file']['error']. "</br>";
}
else
{
echo "File Name: " . $name . "</br>";
echo "File Type: " . $fileType . "</br>";
echo "File Size: " . $size . "</br>";
}
if (file_exists($file_location, $name))
{
echo "File already exists!" . $name . "</br>";
}
else
{
move_uploaded_file($tempname, $fileLocation.$name);
echo "Stored in: " . $fileLocation . "</br>";
}
}
?>
HTML CODE:
<form enctype="multipart/form-data" action="uploadFile.php" method="POST">
Send this file: <input name="file" type="file" id='file'/>
<input type="submit" value="Send File" name="submit"/>
</form>
Thank you for your response.
Also, check if Your HTML form has enctype='multipart/form-data'
attribute set. It's easy to forget about it (at least I do almost every time).