devster Posted February 12, 2010 Share Posted February 12, 2010 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. Quote Link to comment Share on other sites More sharing options...
phpstuck Posted February 12, 2010 Share Posted February 12, 2010 { move_uploaded_file($temp, "uploads/".$name); echo "Upload complete! Please use your browser to navigate back"; include_once 'nameof page.php'; } } ?> Quote Link to comment Share on other sites More sharing options...
gizmola Posted February 12, 2010 Share Posted February 12, 2010 My suggestion would be to popup a new window for your upload form. Alternatively you could could put it in a div with an iframe, or some variation of same. Then you can just indicate that the upload is complete. Make the window small and design it so it looks like a normal modal dialogue box, and onclick willl just window.close(). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.