jeudi 30 juin 2016

How to download a file from server using AJAX? [on hold]

                function downloadFinalFunc(){
                    var project_id = 3;
                    var xhttp = new XMLHttpRequest();
                    xhttp.onreadystatechange = function () {
                        if (xhttp.readyState == 4 && xhttp.status == 200) {
                            
                            if(xhttp.response)
                            window.location.href=xhttp.response;

                        }
                    };
                    xhttp.open("GET", "http://localhost:8080/downloadFinal.php?PID=" + project_id, true);
                    xhttp.send();
                }
<input type="button" onclick="downloadFinalFunc()">

I am working on a Portal in which user can upload files and admin can download those submissions. The files are uploaded on server correctly in upload folder. Now admin wanted to download it. I have written php script and it downloads file by using request parameter in url.

But by ajax it is not working. Please tell the problem and solution.




Aucun commentaire:

Enregistrer un commentaire