Skip to content
Advertisement

image rotation script

So I have this script that will rotate images located in a directory, which works great. However, it requires a refresh of the page in order to rotate the image. Is there a way I can modify this to have it rotate the image when the image itself is clicked? Thanks in advance

HTML:

JavaScript

PHP:

JavaScript

Advertisement

Answer

Update: this is very basic but test it out and see if it works;

JavaScript

and in your php add a content header to send the image eg if it is a gif or png…

JavaScript

The idear is to set the header content type and to read and write the file to the output buffer using readfile, armed with this you could use ajax as another means to request the image and using the status to easly display a loading indicator.

If you where to Rewrite the URL you could change the extension of .php for the src or not even have an extention.

http://php.net/manual/en/function.pathinfo.php

using pathinfo 'extension' you can get the extention and then set the approprate Content-type

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement