This is not going to work. I do not think you understand what the code does. You will need to acquire knowledge of the following areas:
1.
Learn HTML[
^]
2.
Learn JavaScript[
^]
3.
Learn AJAX[
^]
4.
Learn jQuery[
^]
5.
Learn PHP[
^]
You should learn these with patience and try out their examples. Remember that "
Rome was not built in one day".
However, to relieve you of your immediate anxiety, you may check this out:
ajax-file-upload-jquery[
^],
Good luck.
+++++++++++++++++++++++++++++++++++
[This part is added in respond to your follow-up comment]
Yes, the complete code presented at the end of the link is working, no question about it. The problem lies in you do not know how to adapt it. You cannot just copy and paste some code from somewhere and expect it to work out of the box. You will have to modify and adapt it. And the pre-condition for this is that you must have knowledge of the code. That bring you back to the first part of my solution.
To help you further, if you run the code from the link without changes, then when you upload a file it will complain of "no such file or directory", the remedy is: in the "upload.php" file -
1. remove the
$output_dir = "uploads/";
2. replace
move_uploaded_file($_FILES["myfile"]["tmp_name"],$output_dir. $_FILES["myfile"]["name"]);
with
move_uploaded_file($_FILES["myfile"]["tmp_name"],$_FILES["myfile"]["name"]);
That should do. Lastly,
"luck" is elusive but "Learning" stays.