page.php?img=...jpg <- How to place an image after a file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
digi-what
Forum Newbie
Posts: 4
Joined: Sat Nov 01, 2008 8:23 am

page.php?img=...jpg <- How to place an image after a file

Post by digi-what »

Hello.

I am trying to have a php file load an image so it appears in the lURL. Such as: file.php?img=1.jpg

If anyone knows an easy solution to this, please let me know. Some sites say I have to encode it to base64, and if that is the case, how would I encode it to create an image with the above URL?

Thank you
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: page.php?img=...jpg <- How to place an image after a file

Post by aceconcepts »

You could send the file as seperate variables: ?filename=pic1&ext=jpg

Use explode to seperate the filname and ext by use of the fullstop:

Code: Select all

explode(".", $filename);
mmj
Forum Contributor
Posts: 118
Joined: Fri Oct 31, 2008 4:00 pm

Re: page.php?img=...jpg <- How to place an image after a file

Post by mmj »

digi-what wrote:Hello.

I am trying to have a php file load an image so it appears in the lURL. Such as: file.php?img=1.jpg

If anyone knows an easy solution to this, please let me know. Some sites say I have to encode it to base64, and if that is the case, how would I encode it to create an image with the above URL?

Thank you
Where are the image contents stored?

You can have it stored in a db the php file or just read an image file and it would work. You just have to send the appropriate headers.
digi-what
Forum Newbie
Posts: 4
Joined: Sat Nov 01, 2008 8:23 am

Re: page.php?img=...jpg <- How to place an image after a file

Post by digi-what »

How would I place the image into a mysql table?

As a file blob in base64 format? All the images are jpgs, so how would I convert that properly, and then take it out of the table to read: xxx.php?img=xx.jpg?
mmj
Forum Contributor
Posts: 118
Joined: Fri Oct 31, 2008 4:00 pm

Re: page.php?img=...jpg <- How to place an image after a file

Post by mmj »

digi-what wrote:How would I place the image into a mysql table?

As a file blob in base64 format? All the images are jpgs, so how would I convert that properly, and then take it out of the table to read: xxx.php?img=xx.jpg?
You must have a specific reason for wanting to store them specifically in a database.

You can store binary data in mysql, its called blob
Post Reply