Answer the question
In order to leave comments, you need to log in
How to download an image file from an external link?
Hello everyone, here is the code
$picture_url="Ссылка на файл";
$item_id="id товара";
$item_name="название товара";
$uploaddir = "../images/item/$item_id";
if (!is_dir($uploaddir)){
mkdir($uploaddir,0755);
}// if is_dir
$ext = getExtension($big_photo);
$bphoto = "".(translit($item_name))."-b$item_id.".$ext;
$sphoto = "".(translit($item_name))."s$item_id.".$ext;
$ubphoto = $uploaddir."/".$bphoto;
$usphoto = $uploaddir."/".$sphoto;
$uploadfileb = $uploaddir."/".$bphoto;
$uploadfiles = $uploaddir."/".$sphoto;
// Копируем файл в files
file_put_contents($uploadfileb, file_get_contents($picture_url));
file_put_contents($uploadfiles, file_get_contents($picture_url));
Answer the question
In order to leave comments, you need to log in
file_get_contents() returns the contents of a file in a string
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question