Jump to content

[SOLVED] blah.png to run PHP script


lamorra

Recommended Posts

I want users to be able to do like "http://site.com/sigs/theirusernamehere.png" and a PHP script is ran that takes the name they put before the .png if the image doesn't already exist.

 

I am guessing I'm going to need to use a .htaccess along with PHP, but I have no clue how to make it happen. I do know how to make the image and put their name on it.

 

Any help would be awesome!

Link to comment
https://forums.phpfreaks.com/topic/159401-solved-blahpng-to-run-php-script/
Share on other sites

http://us.php.net/manual/en/function.imagestring.php for the image part, I suggest you get it working off a normal $_GET first, then later on if you want to use .htaccess to create  an url without any ? & stuff in it you can have a look at

http://www.sitepoint.com/article/search-engine-friendly-urls/

I already know how to make images. I want the user to be able to go to "http://example.com/directory/sigs/BLAH.png" and if BLAH.png isn't created, create it. If it is, output the image.

 

Meaning, I don't want people to have to go to some other page, fill out a form/send variablesthrough the URL, and then it generates an image. I want the code to grab the BLAH part of the BLAH.png and create a sig based on that. I know it can be done, I've seen it before. I just can't think of how to go about doing this.

RussellReal: check your typos.

 

Try this -

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} ^.*\.png$
RewriteRule ([a-zA-Z]+)\.png$ path/to/file.php?username=$1

I assume their name has only letters.

oh yeah, RewriteEngine, no he doesn't need the conds, if the regex is looking for .png

 

RewriteEngine on
RewriteRule ^blah.png$ blah.php

 

well, okay, the first rewrite cond, could be useful, but the second one is excessive :)

Ahh last minute question.

 

With this part:

RewriteCond %{REQUEST_FILENAME} !-f

 

Will that make the image creation script run again if I allowed _ and - in the name? Like "blah-1.png" creates the image, then they go to "blah_1.png"? I am going to allow those 2 characters in their names, and will just replace one for the other in when the image saves.

Hi

 

Having only briefly played with .htaccess (and then having problems with it being inconsistant, as though it was cached), can I ask a quick question about this:-

 

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} ^.*\.png$
RewriteRule ([a-zA-Z]+)\.png$ path/to/file.php?username=$1

 

Do I take it the first RewriteCond checks the file (say, Blah.png) exists, while the 2nd checks that the requested file is a png file? Also I take it that if both these conditions are met then the RewriteRule is invoked, and that would do take a requested file of blah.png and redirect to path/to/file.php?username=blah, or path/to/file.php?username=blah.png?

 

Thanks as this is useful.

 

All the best

 

Keith

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.