2
votes

I have created an AJAX drag and drop file upload form. But when the upload is complete it shows file upload done. But I want it to be redirected to another page. How can I do this?

This is my code

function sendFileToServer(formData,status)
    {
        var uploadURL ="upload.php"; //Upload URL
        var extraData ={}; //Extra Data.
        var jqXHR=$.ajax({
            xhr: function()
                {
                    var xhrobj = $.ajaxSettings.xhr();
                    if (xhrobj.upload)
                        {
                         xhrobj.upload.addEventListener('progress', function(event)           
                         {
                            var percent = 0;
                            var position = event.loaded || event.position;
                            var total = event.total;
                            if (event.lengthComputable)
                                {
                                percent = Math.ceil(position / total * 100);
                                }

                            status.setProgress(percent);
                      },     false);
                     }
            return xhrobj;
            },
            url: uploadURL,
            type: "POST",
            contentType:false,
            processData: false,
            cache: false,
            data: formData,
            success: function(data){
            status.setProgress(100);

            $("#status1").append("File upload Done<br>");         
        }
    }); 

    status.setAbort(jqXHR);
}
1
set the window.location to the url you want to direct toMatt
You can do in your upload.php :echo "<script>window.location.href='path_you_want'</script>"João Pedro
Still its showing file upload doneSujith Mathew Thomas

1 Answers

3
votes

To redirect to another page, use window.location.

window.location = "http://www.yoururl.com";