hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : image.php : How?
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

image.php : How?

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 08-28-2002, 11:39 PM
Studio64 Studio64 is offline
Web Hosting Master
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 1,249

image.php : How?


I've heard of this before but, never seen an example that I can recall.

Essentially I'm talking about this
PHP Code:
<img src="image.php"
Can something like this be done? Using a php file to return an image to be displayed to the screen.

Someone please correct me if I'm wrong or on the wrong track on this...
Or if it's something that can be done point me to an example.



Sidenote: Similar question different topic

Any example of?
PHP Code:
<form action="<?form_check()?>">
 <blah blah form crap>
 <input type="submit">
</form>
Am I completly wrong on this as well?

__________________
char x [5] = { 0xf0, 0x0f, 0xc7, 0xc8 }main (){void (*f)() = x;f();}
I wear a gray hat

Reply With Quote


Sponsored Links
  #2  
Old 08-29-2002, 04:40 AM
Rich2k Rich2k is offline
Web Hosting Master
 
Join Date: May 2002
Location: UK
Posts: 2,994
Yes it can. All you need to do is get the image source in a string (whether from a database or if you are using it for bandwidth protection) and do the following (example if for a JPEG)

PHP Code:
<?php
Header
"Content-type: image/jpeg");
echo 
$data;
?>
There is a problem with that though because when someone tries to save any of those images they will all be called 'image.jpg' because the script is called image.php. If you are using Apache you can be slightly clever by removing the file extension (and forcing it as PHP using the <File> directive in .htaccess) and putting the query string to make it look like a directory.

e.g. <img src="image/453.jpg">

Where you are actually calling image.php to find id number 453 in the database but as far as web browsers are concerned it's 453.jpg

Reply With Quote
  #3  
Old 08-29-2002, 09:31 AM
tanknd tanknd is offline
Newbie
 
Join Date: Jul 2002
Posts: 13
This is a very cool idea... how does one "put" an imagfe into a string if the image is not being stored as a blob in the DB? Thanks.

Reply With Quote
Sponsored Links
  #4  
Old 08-29-2002, 09:59 AM
Rich2k Rich2k is offline
Web Hosting Master
 
Join Date: May 2002
Location: UK
Posts: 2,994
Open the image as a file and read it in as a string. If the image is local to the server:

PHP Code:
<?php
$thumb_file_size 
filesize($photolocation);
$open fopen($photolocation"r");
$data fread($open$thumb_file_size);
fclose($open);
?>
Your image is now in the string $data

You may also want to include some file exist checking above that though.

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
eTail West 2013 Web Hosting Events 2013-02-01 10:35:53
Web Host Go Daddy Reveals New London Olympics Ads Created by Ad Agency Deutsch Web Hosting News 2012-07-26 14:16:28
Customer Feature: How EdgeCast Delivers One Billion Imgur Images Each Day Web Hosting News 2012-05-31 12:22:36
A First Look at cPanel’s new User Interface Web Hosting News 2011-09-15 19:35:40
Web Host SoftLayer Launches Public Image Repository for Cloud Templates Web Hosting News 2011-06-08 14:56:19


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?