I have an input field:
<input type="file" id="inputID" name="file">
When a button is clicked to submit, a JavaScript function will run (url: upload.php). I need to be able to access $_FILES["inputID"]["tmp_name"]
from this input field so that I could use it on upload.php
as,
move_uploaded_file($_FILES["inputID"]["tmp_name"], $target_file)
Is this possible?
At the moment, I get an error:
Notice: Undefined index: inputID
Any help would be very much appreciated.
Thanks so much! :-)
move_uploaded_file()
is a php function, running on a PHP-based server-side application.
It is handled by PHP when your form has been submitted.
You cannot access it from JavaScript before it has been sent, whatever would be the way you would submit it, both asynchronously with an XHR Request, or directly submitting the form to its handler route.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With