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
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Thanks for the replies, sorry for the long response time...

 

Anyways, I used Ken2k7's way since he is spot on to what I'm trying to do (as well as RusselReal). Thanks for all of your help, didn't imagine it would mostly deal with the .htaccess...

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.