create a website that will:
- let the user upload either a .gif or a .doc
- have radio buttons on the form to determine if the code should overwrite a file with the same name or not.
- a password should be in the php to authorize the request
- echo the descriptions of the results back to the uploader
This is my form:
Code:
<html>
<head>
<title>IT 202 Assignment 8</title>
<!-- <link rel="stylesheet" type="text/css" href="assignment7.css"> -->
</head>
<body>
<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="radio" name="overwrite" value="overwrite"> Overwrite the file?<br>
<input type="submit" value="Upload" />
<input type="reset" value="RESET!"/>
</form>
</body>
</html>
this is my php code
Code:
<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
//This is our size condition
if ($uploaded_size > 30000)
{
echo "Your file is too large.<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<br>"
echo $_FILES["uploadedfile"][ "name" ]
echo $_FILES["uploadedfile"][ "type" ]
echo $_FILES["uploadedfile"][ "size" ]
echo $_FILES["uploadedfile"][ "error "]
echo $_FILES["uploadedfile"][ "tmp_name" ]
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>
I'm not sure how to limit the filetype to gifs or docs, i've searched a few pages but nothing works for me and everything says something different. I'm also not sure how to get the radio button to work with the php to overwrite or how to get the password in there
Bookmarks