I'm trying to create a form that allows me to upload only html files to a web directory via php and then delete them after 24 hours of being on my server. Whenever I go to upload a file I just get a blank white page. Can somebody help me figure this out please? Many thanks!
<?php
if (($_FILES["uploaded"]["type"] == "html")
{
$target = "users/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
echo "File: " . $_FILES["uploaded"]["name"] . "<br />";
echo "Type: " . $_FILES["uploaded"]["type"] . "<br />";
echo "Size: " . ($_FILES["uploaded"]["size"] / 1024) . " Kb<br />";
echo "Location: users/" . $_FILES["uploaded"]["name"];
$files=shell_exec('find /users/ -mmin +1440');
$file = explode("
",$files);
if(isset($file) && is_array($file))
{
foreach($file as $val)
{
@unlink($val);
}
}
}
else
{
echo "Sorry, " . $_FILES["uploaded"]["name"] . " is not a valid html document. Please try again.";
unlink . $_FILES["uploaded"]["name"];
}
?>
There is a missing parentheses closing first IF. Then at that last line unlink . $_FILES["uploaded"]["name"];
you probably mean unlink() Blank page makes me think you have error reporting off. Turn it on when you code :)
<?php
if(($_FILES["uploaded"]["type"] == "html")){
$target = "users/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
echo "File: " . $_FILES["uploaded"]["name"] . "<br />";
echo "Type: " . $_FILES["uploaded"]["type"] . "<br />";
echo "Size: " . ($_FILES["uploaded"]["size"] / 1024) . " Kb<br />";
echo "Location: users/" . $_FILES["uploaded"]["name"];
$files=shell_exec('find /users/ -mmin +1440');
$file = explode("
",$files);
if(isset($file) && is_array($file))
{
foreach($file as $val)
{
@unlink($val);
}
}
}
else {
echo "Sorry, " . $_FILES["uploaded"]["name"] . " is not a valid html document. Please try again.";
unlink($_FILES["uploaded"]["name"]);
}
?>