Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require uploader.php;
- //General Error Check
- if ($_FILES["file"]["error"] > 0){
- echo "<SCRIPT>alert('Sorry, there has been an error while uploading Please Try Again');</SCRIPT>";
- echo "Return Code: ".$_FILES["file"]["error"]."<br>";
- //redirect to the main upload page
- die(reciever.php);
- header("Location:uploader.php");
- }else{
- echo "Upload: ".$_FILES["file"]["name"]."<br>";
- echo "<SCRIPT>alert('File Uploaded Successfully !');</SCRIPT>";
- }
- //Image Extention Check
- if( $_FILES["file"]["type"]=='jpg' || 'gif' || 'tif' || 'bmp'|| 'doc' || 'docx' ||'xls'||'xlsx'){
- echo "Type: ".$_FILES["file"]["type"]."<br>";
- }else{
- echo"Error, Extentions other than pictures or documents is prohibited"."<br>";
- }
- //Check File Size
- if($_FILES["file"]["size"] / 1048576 > 5){ //Larger than 5 MB is prohibited
- echo"File size IS LARGER than 5 MB \r\n Return Code:".($_FILES["file"]["error"])."<br>";
- }else{
- echo "Size:".($_FILES["file"]["size"] / 1048576)." MB <br>";
- }
- echo "Temp file:". $_FILES["file"]["tmp_name"]."<br>";
- //Check if File's already been uploaded
- if (file_exists("upload/".($_FILES["file"]["name"]))){
- echo $_FILES["file"]["name"] . " already exists.";
- // If it's not uploaded , then :
- }else{
- //Then Save it !
- move_uploaded_file($_FILES["file"]["tmp_name"],"upload/".$_FILES["file"]["name"]);
- echo "Stored in: "."upload/" . $_FILES["file"]["name"]."<br>";
- }
- ?>
Add Comment
Please, Sign In to add comment