Hello,
In my project I have a form with many inputs and one object is using DropzoneJS to attach files.
Since I store all the inputs when I post the form I need somehow to read the file names of the uploaded files in my server,
currently I can only get the list of the original filename of the files that are uploaded.
For many reasons when a file is uploaded I am giving it a random name with time() function.
A part of my HTML form
<form id="appointment-form" class="box-body no-padding">
<input name="firstname" type="text" />
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 no-padding">
<div class="form-group">
<form id="uploadInput" method="post" action="upload.php" class="dropzone">
<div class="fallback">
<input name="file" type="file" />
</div>
</form>
</div>
</div>
<button type="button" class="btn btn-default btn-flat">
<i class="fa fa-plus"></i> Add
</button>
</form>
upload.php
<?php
$ds = DIRECTORY_SEPARATOR;
$storeFolder = 'files/tmp';
if (!empty($_FILES)) {
$tempFile = $_FILES['file']['tmp_name'];
$targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds;
$path_parts = pathinfo($_FILES["file"]["name"]);
$extension = $path_parts["extension"];
$targetFile = $targetPath . time() . '.' . $extension;
echo $targetFile;
move_uploaded_file($tempFile, $targetFile);
}
?>
How can I store the $targetFile in my HTML form so I can read them when I post the main form?!