Jump to content

Recommended Posts

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

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.

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

echo $output;
?>

 

but this results in null

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....

Edited by jazzman1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.