2

Is it possible to pass through an image file from a remote URL, without downloading it to the local server?

I have a PHP script that tracks stats and then outputs an image via readfile(). Example:

<img src="http://example.com/image.php?img=1234">

I'd like to use a CDN to reduce load, and take advantage of geo-location services to serve images faster. So, the script needs to output the image straight from the CDN and not download it to the local server for output.

Any advice on how to achieve this? Is it possible? Thanks in advance!

2 Answers 2

4

Do your tracking, but send the browser to the real location afterwards.

See: http://php.net/manual/en/function.header.php

<?php
header("HTTP/1.0 303 See Other");
header("Location: %the real uri%");
Sign up to request clarification or add additional context in comments.

Comments

0

If you know the name and the location of the image on the remote server you can just use their webspace and only pass through the imagename.

Then in your code you hardcode the imagepath and give the imagename as a dynamic parameter..

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.