Last active
December 20, 2015 05:59
-
-
Save codesynapse/6082642 to your computer and use it in GitHub Desktop.
File Upload using PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>File Upload Example</title> | |
</head> | |
<body> | |
<form method="post" action="upload.php" enctype="multipart/form-data"> | |
<label> Upload your file</label><br/> | |
<input type="file" name="file" id="file"><br/> | |
<input type="submit" name="submit"> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>File Upload Status</title> | |
</head> | |
<body> | |
<?php | |
//by using $_files array you can store data from client computer to the remote server | |
//check if the file is uploaded, if not then pass the error | |
if($_FILES['file']['error']>0) { | |
echo 'Error :'.$_FILES['file']['error']."<br/>"; | |
} | |
//if the file is uploaded successfully, echo the file size, type and location | |
echo "Upload ". $_FILES['file']['name']."<br/>"; | |
echo "Type ". $_FILES['file']['type']."<br/>"; | |
echo "Size ".($_FILES['file']['size']/1024) ."<br/>"; | |
echo "Stored in :".$_FILES['file']['tmp_name']."<br/>"; | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment