By 'copying' in this case you actually mean 'downloading': You need to download some file of another server via http, and save it to a local folder.
Depending on how your server is setup, and which types of files you want to download the easiest way is basically :
- checking the URL for a filename with extension
- making sure the extension is allowed to be downloaded
- using file_get_contents($url); to download the file into a variable
- saving the file to your path with the same name / extension.
In plain php this would be something like:
$allowedExtensions = ['csv', 'doc', 'pdf', 'jpg'];
$path = public_path('datafiles\APPL');
$url = request('cand_resume_url');
$fileName basename($url);
$extension = pathinfo($filename, PATHINFO_EXTENSION);
if(array_search($extension, $allowedExtensions) === false) {
throw new \Exception($extension .' is not allowed');
}
if(file_exists($path . $fileName)) {
throw new \Exception('File exists');
}
file_put_contents($path .'/'. $fileName, file_get_contents($url));