I have found a php script that I want to use on my website it works fine but the problrm is that it lets me upload anything ,and I want it to be restricted to jpgs no larger than 2mb.
I dont know to much about php scripts but it seems that its coded to do this but it still accepts any file.I know this can be a problem with spam.
Heres is the script, can anybody see what the problem is ?
Thanks
<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
//This is our size condition
if ($uploaded_size > 2000000)
{
echo "Your file is too large.<br>";
$ok=0;
}
//This is our limit file type condition
if ($uploaded_type ==".jpg")
{
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 please go away now";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>
I dont know to much about php scripts but it seems that its coded to do this but it still accepts any file.I know this can be a problem with spam.
Heres is the script, can anybody see what the problem is ?
Thanks
<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
//This is our size condition
if ($uploaded_size > 2000000)
{
echo "Your file is too large.<br>";
$ok=0;
}
//This is our limit file type condition
if ($uploaded_type ==".jpg")
{
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 please go away now";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>