How to capture mouse cursor location over my uploaded image in html and php? -
i want write text on uploaded image. using html , php. same, trying save position of mouse cursor user clicks on image write text. have tried these things below. shows error in click.php.
index.php
<form action="click.php" method="post" enctype="multipart/form-data"> <h3>select image upload:<br/></h3> <input type="file" name="filetoupload" id="filetoupload" accept="image/*"/> <input type="submit" value="upload image" name="submit"/> </form>
click.php
<script> function getpos(e){ x=e.clientx; y=e.clienty; cursor="your mouse position : " + x + " , " + y ; document.getelementbyid("displayarea").innerhtml=cursor } function stoptracking() { document.getelementbyid("displayarea").innerhtml=""; } </script> <div id="focusarea" onmousemove="getpos(event)" onmouseout="stoptracking()"> <?php $target_dir = "uploads/"; $target_file = $target_dir . basename($_files["filetoupload"]["name"]); //set content type header("content-type: image/png"); #dispaly image $file = $_post['file']; echo file_get_contents($file); ?> </div> <p id="displayarea"></p>
please try this
$(document).ready(function(e) { $('#a').click(function(e) { alert(e.pagex+ ' , ' + e.pagey); }); });
Comments
Post a Comment