/ Published in: PHP

General file upload script in php. Error set using SESSIONS.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
} $max_size = 10000; // maximum file size, in KiloBytes $file = $ref_id; //Name of file when uploaded // Checks if the file has allowed type and size $_SESSION['status'] = 1; echo '<script> window.location.href = "redirect.php"; </script>'; } if ($_FILES['fileToUpload']['size'] > $max_size * 1000) { $_SESSION['status'] = 2; echo '<script> window.location.href="redirect.php"; </script>'; } $uploadpath = 'directory/' . $file; // gets the file name } else { $_SESSION['status'] = 3; echo '<script> window.location.href = "redirect.php"; </script>'; } }
Comments
