I want to grab files put into the form into a folder in the same directory all i have is the form and a the javascript for the file to be able to get selected
<form>
<div id="filejs" class="file is-info has-name">
<label class="file-label">
<input class="file-input" type="file" name="stuff" />
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label"> </span>
</span>
<span class="file-name"> Upload file </span>
<input class="button" type="submit" value="Submit input" />
</label>
</div>
</form>
<script>
const fileInput = document.querySelector("#filejs input[type=file]");
fileInput.onchange = () => {
if (fileInput.files.length > 0) {
const fileName = document.querySelector("#filejs .file-name");
fileName.textContent = fileInput.files[0].name;
}
};
</script>
You can not get uploaded files from a form with client-side Javascript. You will require any backend technology for this job. You can use node.js as it is an asynchronous event-driven JavaScript runtime environment. There are many free packages available that can handle form files and form data like multer, formidable, form-data etc.
Also, you can check out the PHP form handling method here.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments