Hi folks,
I was wondering if someone could help me. This is more of a feature than a necessity for my website, but it would be nice.
Basically, I have an upload form where users can upload certain files to the site. We've all seen it. I want it so that after the upload is either successfully uploaded or they get the 'wrong file type' error, I want to either re-direct them back to the home page or back to the uploads page automatically, or within 5 seconds or something.
The uploads section is fairl straighforward. Here is some of the offending code:
The form:
<form action="upload.php" method="post" enctype='multipart/form-data'>
<input type="file" name="myfile"><p>
<input type="submit" value="Upload">
</form>
The php script that checks everything:
<?php
//Properties of uploaded file
$name = $_FILES["myfile"]["name"];
$type = $_FILES["myfile"]["type"];
$size = $_FILES["myfile"]["size"];
$temp = $_FILES["myfile"]["tmp_name"];
$error = $_FILES["myfile"]["error"];
if ($error > 0)
die("Error uploading file!");
else
{
//Conditions for the file type
if($type !== "application/octet-stream")
{
die ("Wrong file type. Please use your browser to navigate back");
}
else if($size > 152000000)
{
die ("File too big. Maximum file size is 80Mb");
}
else
{
move_uploaded_file($temp, "uploads/".$name);
echo "Upload complete! Please use your browser to navigate back";
}
}
?>
Thank you all for your help.
Best regards,
Dev.