Created
April 4, 2019 14:04
-
-
Save dreamstarter/43f27cd93da742d1f8062bba9f7d92bd to your computer and use it in GitHub Desktop.
php file upload form
This file contains hidden or 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> | |
<head> | |
<title>File Upload</title> | |
</head> | |
<body> | |
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data"> | |
<input type="file" name="csv_file"> | |
<input type="submit" name="submit"> | |
</form> | |
<?php | |
if(isset($_POST['submit'])) { | |
if ($_FILES['csv_file']['size'] > 0) | |
{ | |
echo "<p>".$_FILES['csv_file']['name']." => file input successfull</p>"; | |
fileUpload(); | |
} | |
} | |
function fileUpload () { | |
$target_dir = "var/import/"; | |
$file_name = $_FILES['csv_file']['name']; | |
$file_tmp = $_FILES['csv_file']['tmp_name']; | |
if (move_uploaded_file($file_tmp, $target_dir.$file_name)) { | |
echo "<h1>File Upload Success</h1>"; | |
} | |
else { | |
echo "<h1>File Upload not successfull</h1>"; | |
} | |
} | |
?> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment