RotsjK Posted May 26, 2013 Share Posted May 26, 2013 Hi, i need to process an onix file (kind of xml). This was no problem, but in this onix file the images belonging to the products are a link to a script. When i open the url in my browser, automatically the image is downloaded to my pc. What can i do to use this link and save this image on my webserver? I tried file_get_contents but i did not succeed... This is an example of the url: https://cbonline.boekhuis.nl/pls/cover/p_get_cover_fe?p_hash=9C099FC9E2626377495DA02FD7F802B0 Thanks. Link to comment https://forums.phpfreaks.com/topic/278401-need-help-with-an-image-url/ Share on other sites More sharing options...
jazzman1 Posted May 26, 2013 Share Posted May 26, 2013 I downloaded your image by this unix command: [jazz@centos-box ~]$ wget 'https://cbonline.boekhuis.nl/pls/cover/p_get_cover_fe?p_hash=9C099FC9E2626377495DA02FD7F802B0' --2013-05-26 10:37:05-- https://cbonline.boekhuis.nl/pls/cover/p_get_cover_fe?p_hash=9C099FC9E2626377495DA02FD7F802B0 Resolving cbonline.boekhuis.nl... 194.229.60.195 Connecting to cbonline.boekhuis.nl|194.229.60.195|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 79913 (78K) [image/jpeg] Saving to: “p_get_cover_fe?p_hash=9C099FC9E2626377495DA02FD7F802B0” 100%[=====================================================================================================================================================================>] 79,913 135K/s in 0.6s 2013-05-26 10:37:06 (135 KB/s) - “p_get_cover_fe?p_hash=9C099FC9E2626377495DA02FD7F802B0” saved [79913/79913] You could use the shell_exec function in php to pass the URL like variable. Link to comment https://forums.phpfreaks.com/topic/278401-need-help-with-an-image-url/#findComment-1432365 Share on other sites More sharing options...
RotsjK Posted May 27, 2013 Author Share Posted May 27, 2013 I don't seem to understand the shell_exec function. What is it that it's suppose to do? Pass me the direct url from the image so i can handle it? I tried this: <?php $output = shell_exec("https://cbonline.boekhuis.nl/pls/cover/p_get_cover_fe?p_hash=9C099FC9E2626377495DA02FD7F802B0"); echo $output; ?> but this results in null Link to comment https://forums.phpfreaks.com/topic/278401-need-help-with-an-image-url/#findComment-1432481 Share on other sites More sharing options...
jazzman1 Posted May 27, 2013 Share Posted May 27, 2013 Example 1: //Get the file from the remote machine $src = file_get_contents("https://cbonline.boekhuis.nl/pls/cover/p_get_cover_fe?p_hash=9C099FC9E2626377495DA02FD7F802B0"); //Store the image $fp = fopen("image.jpg", "w"); fwrite($fp, $src); fclose($fp); echo '<img src="image.jpg" alt="someImage" />'; Example 2: header("Content-Type: image/jpeg"); $src = 'https://cbonline.boekhuis.nl/pls/cover/p_get_cover_fe?p_hash=9C099FC9E2626377495DA02FD7F802B0'; $output = "image.html"; shell_exec("wget -q $src -O $output"); echo file_get_contents($output); There is a lot of options to download images from the remote machine and save it to the local one. CURL is an option also.... Link to comment https://forums.phpfreaks.com/topic/278401-need-help-with-an-image-url/#findComment-1432522 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.