Hi can someone help me out, please. I have been using the same file upload script on three websites that I manage, with great success. But recently I have encountered some errors when accessing the file upload form on my locahost server on my own computer server. This has never happened before.
The following errors appear:
Notice: Undefined index: uploaded in C:\xampp\htdocs***************\upload_file.php on line 16
**Notice: Undefined variable: uploaded_size in C:\xampp\htdocs*****************\upload_file.php on line 20
Notice: Undefined variable: uploaded_type in C:\xampp\htdocs*****************\upload_file.php on line 25
Notice: Undefined index: uploaded in C:\xampp\htdocs*****************\upload_file.php on line 35
These errors do not appear on the live websites, but only on my home server. I can still upload a file successfully while receiving these errors on my home computer.
I have tried to fix this problem up, but with no success.
Can someone help me out please?
File Upload Script:
<?php
$target = "uploads/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
//This is our size condition
if ($uploaded_size >2950000){
echo "Your file is too large.<br>";
$ok=0;
}
//This is our limit file type condition
if ($uploaded_type =="text/php"){
echo "No PHP files<br>";
$ok=0;
}
//Here we check that $ok was not set to 0 by an error
if ($ok==0){
echo "Sorry your file was not uploaded";
}
//If everything is ok we try to upload it
else {
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)){
echo "
The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
// else {
// echo "Sorry, there was a problem uploading your file.";
//}
}
?>
</div>
<form enctype="multipart/form-data" action="upload_file.php" method="POST">
<fieldset>
<legend> Upload File | <a href="viewFile.php" class="apageLinks">View File List</a> | 
<a href="menu.php" class="apageLinks">Main Menu</a> | 
<a href="logout.php" class="apageLinks">Log out</a> 
</legend><br /><br />
Please choose a file:<input name="uploaded" type="file" /><br /><br />
<input name="submit" type="submit" value="Submit" class="form" /><br />
</fieldset>
</form><br />