To make it simple:
- I have an image file ex: https://www.example.com/a/b/c/image.jpg
- I want to use curl to download and save the image on my server but I want to keep the directory structure, so I want to save the file on my server to a/b/c/image.jpg , so the directories must also be created if they do not exist already
- If the file already exist to not download
Hope someone with more experience can help because I have tried 2 days on this an nothing.
For now I only have the CURL function that is working good:
$curl = curl_init();
curl_setopt( $curl, CURLOPT_URL, $urltoget );
curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, true );
$tempsavefile = curl_exec( $curl );
curl_close( $curl );