This is a quick post on the topic of move zip file from server to server using Ajax. Recently, I have worked on the similar task for one of my client website. It may be helpful for someone so I decided to write a post on it.
For this article, I am assuming you have a submit button and you need to fetch zip file from another server. Let’s say server path for a zip file is http://example.com/archieves/test.zip.
Place the below code in your file. In this file, we are giving an Ajax call on the clicking of a button. To the Ajax file, we send a source path of a zip file.
Next, in ajax.php file we write actual code to move zip file from server to server. Below is the code in ajax.php file.
<?php $arr_file = explode("/", $_POST['source']); $filename = end($arr_file); file_put_contents($filename, file_get_contents($_POST['source'])); echo 'success'; ?>
If you liked this article, then please subscribe to our YouTube Channel for video tutorials.