In Part 1 we discussed how to make image draggable using simple jQuery. In this part we will learn how to save the dragged image using PHP . We will crop the part that is outside our view port div (which is of resolution 850x600 ). First retrieve the original width and height of image. To do this we will use getimagesize function of PHP . It takes file path as input and return the array containing width at index 0 and height at index 1 $file_path="movable.jpg" $size=getimagesize($file_path); $width=$size[0]; $height=$size[1]; Get current x and y of image. In the HTML FORM written in Part 1 we have hidden fields with name locationX and locationY containing X and Y co-ordinates respectively. $x=$_POST["locationX"]; $y=$_POST["locationY"]; Next step is to check if any part of image is outside our bounding box (div). We will do this separately for width(horizontal view) and height (vertical view). For horizontal view If sum of curren...
I document random stuff on this Blog. It can be a piece of code , my personal experience, a fun fact or anything else.