Hiya,
Firstly, I'm a complete novice, apologies! But I have got my upload.php working which is nice. I will post the code below.
However, I would now like to restrict the file size and file type to only word documents.
I currently have a restriction of 200KB but it's not working - no idea why as I've looked at other similar codes and they look the same.
Also, just to complicate things - can I stop files overwriting each other when uploaded? At the moment, if 2 people upload files with the same name one will overwrite the other.
Is this too many questions in 1?
Any help is very much appreciated!
Code below:
<form enctype="multipart/form-data" action="careers.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
//This is our size condition
if ($uploaded_size > 200)
{
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 "Your file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded.";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>