Created
June 20, 2018 09:20
-
-
Save jagroop/b30e615991dcc77ea7afe5721ae82afe to your computer and use it in GitHub Desktop.
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
<?php | |
$storeFolder = 'uploads/'; | |
// // if folder doesn't exists, create it | |
// if(!file_exists($storeFolder) && !is_dir($storeFolder)) { | |
// mkdir($storeFolder); | |
// } | |
// echo "<pre>"; | |
// print_r($_POST); | |
// print_r($_FILES); | |
// echo "</pre>"; | |
// die; | |
if (!empty($_FILES)) { | |
// echo "<pre>"; | |
// print_r($_FILES); | |
// echo "</pre>"; | |
// die; | |
/** | |
* uploadMultiple = false | |
* When uploading file by file, upload on fly | |
* | |
*/ | |
// $tempFile = $_FILES['file']['tmp_name']; | |
// $targetFile = $storeFolders . $_FILES['file']['name']; | |
// move_uploaded_file($tempFile,$targetFile); | |
/** | |
* uploadMultiple = true | |
* When uploading multiple files in a single request. | |
* Way to go if using dropzone in a form with other fields, | |
* and when uploading files on form submit via button... myDropzone.processQueue(); | |
* | |
* $_FILES['file']['tmp_name'] is an array so have to use loop | |
* | |
*/ | |
foreach($_FILES['file']['tmp_name'] as $key => $value) { | |
$tempFile = $_FILES['file']['tmp_name'][$key]; | |
$targetFile = $storeFolder. $_FILES['file']['name'][$key]; | |
move_uploaded_file($tempFile,$targetFile); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment