Jump to content

[SOLVED] Working with External Images


Gafaddict

Recommended Posts

Hi guys,

 

At the moment I'm writing a script which deals with the possibility of analyzing a file that is not on my server -- rather, it is located on another server and a completely different domain. Say the image is http://www.example.com/logo.jpg.

 

The script needs to find out the dimensions of logo.jpg when a user inputs that string into a textbox. I know how to get the dimensions of an image on the server, but how would I get the dimensions of an external image? Is it even possible?

 

If that is not possible, how would one go about copying that external image from the URL to their own server? I've seen this done before in phpBB before but they don't seem to have any documentation about it.

 

Thanks in advance,

Link to comment
https://forums.phpfreaks.com/topic/72546-solved-working-with-external-images/
Share on other sites

same way as any other image...

<?php
$path= "http://www.example.com/logo.jpg";
$size = getimagesize($path);
//or even
$path = urlencode($path);
$size = getimagesize($path);
?>

 

EDIT:

also you can use copy to copy the image or imagecreatefromjpeg, providing fopen wrappers have been enabled

Archived

This topic is now archived and is closed to further replies.

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