Download and extract file


For practice, I am trying to download a zip file, extract it to a directory and then copy its contents to another directory. I have it almost working but I am stuck on the copying part and I am not sure that the whole thing is coded as it should be. I would really appreciate any comments and help so I can learn. The code I have so far is below. Thank you in advance.

    <!DOCTYPE html> 
<div align="center">
			Create directory and extract Wordpress 
		<link rel="stylesheet" href="" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
		if (!isset($_POST['submit'])) { 
		<form action = "" method = "post"> 
				<td style = " border-style: none;"></td> 
				<td> <h4>
					Enter new directory name

					<input type = "text" style = "width: 220px;"
					class = "form-control" name = "add" id = "add" /> 

				<td colspan = "2"> 
					<input type = "submit" name = "submit" class = "btn btn-success"
						value = "Create & Extract" /> 
		else { 
$url = "";
$zipFile = "latest/"; // Local Zip File Path
$zipResource = fopen($zipFile, "w");

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt($ch, CURLOPT_FILE, $zipResource);
$page = curl_exec($ch);
if(!$page) {
 echo "Error :- ".curl_error($ch);

$zip = new ZipArchive;
$extractPath = "latest";
if($zip->open($zipFile) != "true"){
 echo "Error :- Unable to open the Zip File";


function createDirectory() { 
	$newDir = $_POST["add"]; 

function mycopy($wpSrc,$newDir) {
	$wpSrc = "latest/wordpress/";
	$path = pathinfo($newDir);

Turn error reporting on and see what’s failing.


Thanks for the suggestions. Error reporting is now on but the script is not throwing any error, it just doesn’t copy the files to the newly created directory.