Hello,
Is it possible from links stored in my database to download all the files to which these links point?
Hello,
Is it possible from links stored in my database to download all the files to which these links point?
Can you please explain a little more detailed what are you trying to achieve?
Hello,
I have a table with example urls: https://www.frou-frou.com/media/catalog/product/5/7/5792f566aa61ee51cf4667d07bb6b9a67e38734ae33085105bf53ec5a2764b7e.jpeg for each link in my table I want the file to be downloaded and stored on my server to then zip it and send it
zip and send I know how to do but by downloading the file
You can’t download files from remote urls to your server with the tools available in server connect.
Hello,
So I go through a php script that I call via the serverconnect api with the url as a variable and it works very well, just loop to download as many files as you want.
<?php
//The URL of the file that you want to download.
$url = 'https://community.wappler.io/uploads/default/original/3X/5/1/5108213e1448c3f2e428c71aed1c4c5f6afdbe81.png';
$tabUrl = parse_url($url);
$fichier =basename ($tabUrl["path"]);
//Download the file using file_get_contents.
$downloadedFileContents = file_get_contents($url);
//Check to see if file_get_contents failed.
if($downloadedFileContents === false){
throw new Exception('Failed to download file at: ' . $url);
}
//The path and filename that you want to save the file to.
$fileName = $fichier;
//Save the data using file_put_contents.
$save = file_put_contents($fileName, $downloadedFileContents);
//Check to see if it failed to save or not.
if($save === false){
throw new Exception('Failed to save file to: ' , $fileName);
}
?>
Correctly is
<!doctype html>
<html>
<head>
<base href="/">
<title>Untitled Document</title>
</head>
<body>
<?php
//The URL of the file that you want to download.
$url = $_GET['url'];
$tabUrl = parse_url($url);
$fichier =basename ($tabUrl["path"]);
//Download the file using file_get_contents.
$downloadedFileContents = file_get_contents($url);
//Check to see if file_get_contents failed.
if($downloadedFileContents === false){
throw new Exception('Failed to download file at: ' . $url);
}
//The path and filename that you want to save the file to.
$fileName = $fichier;
//Save the data using file_put_contents.
$save = file_put_contents($fileName, $downloadedFileContents);
//Check to see if it failed to save or not.
if($save === false){
throw new Exception('Failed to save file to: ' , $fileName);
}
?>
</body>
</html>