download graphics file from my website

User 503620 Photo


Registered User
12 posts

I would like to develop a website but need to give the USER the feature to download graphics / corel draw templates FROM the website. How can i do that ???

I have a php script, how can i incorporate the running of script on website?

I see that i can easily upload files to my website.

Thanks
User 355448 Photo


Ambassador
3,144 posts

clombard,

To download graphics from a website, you can use a PHP script if your server supports PHP. What I have done is have the thumbnail or large image be a link, and the link is changed to point to a php file. If I have a graphic named house.jpg, I insert the file name in this php file twice and name the php file house.php. So my house.php file would look like this:
<?php
$filename = "house.jpg";

header("Content-Length: " . filesize($filename));
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=house.jpg');

readfile($filename);
?>

This has worked well for me, but I do have to create the .php file for each graphic.

If you do not want to use the actual images, you can use anchor tags like this: <a href="house.php">house.jpg</a> and just create a list for your site visitors to click on.

Hope this helps.

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.