I started creating this page that is suppose to upload image files, it opens the file upload box but when i click to submit the file nothing happens. I have checked the folder and no file goes in it. I don't know what i am doing wrong.
Can anyone help please?
<?php
session_start();
if($_SESSION['name']=="hollywincote")
{
echo "Welcome ".$_SESSION['name'];
echo " ";
echo "<a href='logout.php'>Logout</a>";
}
else
{
header("Location:login.php");
}
$page_title= 'Holly Wincote | Login';
include('includes/header.html');
?>
<div class="leftcontent">
<h2>Administrator Panel</h2>
<?php
//check if the form has been submitted:
if(isset($_POST['submitted'])) {
//check for an uploaded file:
if(isset($_FILES['upload'])) {
//validate the type. Should be jpeg or png.
$allowed = array('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png');
if(in_array($_FILES['upload']['type'], $allowed)) {
//move the file over.
if(move_uploaded_file($_FILES['upload']['name'], "../hollywincote/uploads/{$_FILES['upload']['name']}")) {
echo '<p><em>The file has been uploaded</em></p>';
} //end of move... IF
} else {
echo '<p>Please upload a jpeg or png image</p>';
}
} //end of isset($_FILES['upload']) IF.
//check for an error:
if($_FILES['upload']['error'] >0) {
echo '<p>The file could not be uploaded because: <strong>';
//print a message based upon the error.
switch ($_FILES['upload']['error']) {
case 1:
print 'the file exceeds the upload_max_filesize setting in php.ini.';
break;
case 2:
print 'the file exceeds the MAX_FILE_SIZE setting in the html form.';
break;
case 3:
print 'the file was only partially uploaded.';
break;
case 4:
print 'no file was uploaded.';
break;
case 6:
print 'no temporary folder was available.';
break;
case 7:
print 'unable to write to the disc.';
break;
case 8:
print 'file upload stopped.';
break;
default:
print 'a system error occured.';
break;
} //end of switch
echo '</strong></p>';
} //end of error IF.
//delete the file if it still exists
if(file_exists($_FILES['upload']['tmp_name'])) {
unlink ($_FILES['upload']['tmp_name']);
}
}//end of submitted conditional
?>
<form enctype="multipart/form-data" action="admin_panel.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="5242488">
<fieldset>
<legend>Select a JPEG or PNG image of 512kb or smaller to be uploaded:</legend>
<p><b>File:</b> <input type="file" name="upload"/></p>
</fieldset>
<div align="center">
<input type="submit" name="submitted" value="submit"/>
</div>
<input type="hidden" name="submitted" value="TRUE"/>
</form>
</div><div class="clear"></div>
</div>
<?php
include ('includes/footer.html');
?>
also whats the pdf and word document version of these?
'image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png'
thanks
Janette