Good Day
need help, been trying this for so long now, i have a code for move_upload_file() it works very fine when i test the page alone but once i put it on the form on my website it doesnt work?
here is my code - upload_file.php :
<?php
error_reporting(E_ALL);
$allowedExts = array("gif", "jpeg", "jpg", "jpe", "png", "pjpeg", "x-png");
$allowedMimeTypes = array( 'application/msword','text/pdf','image/gif','image/jpeg','image/png');
$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/jpg")
|| ($_FILES["file"]["type"] == "image/jpe")
|| ($_FILES["file"]["type"] == "image/pjpeg")
|| ($_FILES["file"]["type"] == "image/x-png")
|| ($_FILES["file"]["type"] == "image/png"))
&& ($_FILES["file"]["size"] < 500000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
if (file_exists("Images/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
chmod ("Images/", 0775);
if (copy($_FILES["file"]["tmp_name"],"Images/" . $_FILES["file"]["name"])) {
move_uploaded_file($_FILES["file"]["tmp_name"],"Images/" . $_FILES["file"]["name"]);
echo "Stored in: " . "Images/" . $_FILES["file"]["name"];
}
}
}
}
else
{
echo "Invalid file";
}
?>
Inside my form i have this link
<?php
include "/cmsintranet/testing.php";
?>
that is calling a testing.php page which looks like this:
<html>
<body>
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<button type="reset" value="Reset">Reset</button><input type="submit" value="Submit" id="">
</form>
</body>
</html>
Please help me out since am not sure what exactly is the problem whether its my website cos the pages works just fine?