Tuesday, 10 February 2015
Upload file in "php"
PHP FILE UPLOADING CODE
<?php if(isset($_FILES['uploadedfile'])){ $target_path = "upload/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $allowedExts = array("gif", "jpeg", "jpg", "bmp","tif","tiff","png"); $temp = explode(".", $_FILES["uploadedfile"]["name"]); $extension = end($temp); if((($_FILES["uploadedfile"]["type"] =="image/gif") || ($_FILES["uploadedfile"]["type"] == "image/jpeg") || ($_FILES["uploadedfile"]["type"] == "image/jpg") || ($_FILES["uploadedfile"]["type"] == "image/bmp") || ($_FILES["uploadedfile"]["type"] == "image/tif") || ($_FILES["uploadedfile"]["type"] == "image/png")) && ($_FILES["uploadedfile"]["size"] < 1000000) && in_array($extension, $allowedExts)) { if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename($_FILES['uploadedfile']['name']). " has been uploaded"; } } else { echo "There was an error uploading the file, please try again!"; } } ?>
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment