PHP - Help With Jquery Webcam
I'm using jQuery webcam to capture a photo of the client. I need to send it to the server just when the form is submitted (It's a form with information, and I need to have the photo attached to it).
I have everything working except the part of saving the image encoded with base64 to the database like blob. Here is what I have so far: Code: [Select] <script type="text/javascript"> var pos = 0; var ctx = null; var cam = null; var image = null; jQuery("#webcam").webcam({ width: 320, height: 240, mode: "callback", swffile: "/../../js/jscam_canvas_only.swf", onTick: function(remain) { if (0 == remain) { jQuery("#status").text("Sorria!"); } else { jQuery("#status").text(remain + " segundo(s) restante(s)..."); } }, onSave: function(data) { var col = data.split(";"); var img = image; for(var i = 0; i < 320; i++) { var tmp = parseInt(col[i]); img.data[pos + 0] = (tmp >> 16) & 0xff; img.data[pos + 1] = (tmp >> 8) & 0xff; img.data[pos + 2] = tmp & 0xff; img.data[pos + 3] = 0xff; pos+= 4; } if (pos >= 4 * 320 * 240) { ctx.putImageData(img, 0, 0); var canvas = document.getElementById("canvas"); var save_image = canvas.toDataURL("image/png"); save_image = save_image.replace(/^data:image\/(png|jpeg);base64,/, ""); $('input[name=save_image]').val(save_image); pos = 0; } }, onCaptu function () { jQuery("#flash").css("display", "block"); jQuery("#flash").fadeOut(100, function () { jQuery("#flash").css("opacity", 1); }); jQuery("#canvas").show(); webcam.save(); }, onLoad: function () { var cams = webcam.getCameraList(); for(var i in cams) { jQuery("#cams").append("<li>" + cams[i] + "</li>"); } jQuery("#canvas").hide(); } }); function getPageSize() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer if(document.documentElement.clientWidth){ windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if(xScroll < windowWidth){ pageWidth = xScroll; } else { pageWidth = windowWidth; } return [pageWidth, pageHeight]; } window.addEventListener("load", function() { jQuery("body").append("<div id=\"flash\"></div>"); var canvas = document.getElementById("canvas"); if (canvas.getContext) { ctx = document.getElementById("canvas").getContext("2d"); ctx.clearRect(0, 0, 320, 240); var img = new Image(); img.onload = function() { ctx.drawImage(img, 320, 240); } image = ctx.getImageData(0, 0, 320, 240); } var pageSize = getPageSize(); jQuery("#flash").css({ height: pageSize[1] + "px" }); }, false); window.addEventListener("resize", function() { var pageSize = getPageSize(); jQuery("#flash").css({ height: pageSize[1] + "px" }); }, false); </script> Then I have just a normal form that the customer has to fill it in, followed by this: Code: [Select] <div id="webcam"> </div> <p style="width:250px;text-align:center; "><input type="button" value="Tirar Fotografia" onclick="webcam.capture(3);void(0);"/></p></td><td><p><canvas id="canvas" height="200" width="200"></canvas></p> in php i have: Code: [Select] $image=file_get_contents(base64_decode($_POST['save_image'])); Similar Tutorialsi have a chat room where i've created using AJAX n i wonder how can i add a webcam for my chatroom?? Is there anything i mean software to be added or installed?? Any guides?? thanks This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=343384.0 Hi, I am making login page with database and php. I need to be able when the person clicks theogin button to take photo of the person and add it to that same database based on the info entered.
I am doing this to know if that person that logged in is the person in reality.
Is it possible I tried both of these articles, I have a windows 8.1 tablet and both of the different "codes" worked but I tried my friend's iPhone and the camera viewport is just a black square or doesn't show at all... the problem seems to be that the pop up where you push "allow" or "deny" doesn't show up at all, this makes me think the trigger isn't "triggered".
These are the sites
I'm using HTML5 and Javascript, didn't do much modifcation yet, I just needed the basic web cam access, cropping, saving functions at the moment.
http://davidwalsh.name/browser-camera
http://mycodingtrick...ipt/webcam-api/
i cant find any working stuff on this i cant just start learning as3 and flash development for a small feature :\ i found this two guides: http://www.marchawkins.com/2010/03/17/capture-and-upload-a-webcam-still-with-flash/ dont work for me do error couldnt make it work :| http://www.endseven.net/?p=9# didnt work for me to... im beggin you guys i really need this script just a simple snap from webcam and it upload to the site thats it. Hi, I am creating an access control page where my end user swipes his card and the page auto submits. At this stage I want to click his/her picture as well. The challenge is I am unable to find a script where a webcam clicks on page refresh or when it auto submits.. All the scripts i have seen only work on a click which is not possible here as the only user input is a swipe which has an autosubmit. Im wondering if i should use jQuery or Php. and how about i would go about doing this. Code: [Select] <?php print "<table border=\"0\" cellpadding=\"0\" width=\"100%\" height=\"100\"cellspacing=\"0\" style=\"border-collapse:collapse\"bordercolor=\"grey\" bgcolor=\"white\" valign=\"top\"> <td align=\"left\" width=\"100%\" onclick=\"I3.location.href='getuserdetail.php?prop=$ownerid'\"><b>Property Name</b></td><td><b>Tenant</b></td><td><b>Property Status</b></td><td>Rent Amount</td>"; $connect = mysql_connect("localhost","root",""); mysql_select_db("magic"); $query = "SELECT * FROM props WHERE ownerid = '$ownerid' ORDER BY name ASC "; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $propertyid = $row['propid']; $propertyname = $row['name']; $propertydesc = $row['description']; $propertycity = $row['city']; $propertystate = $row['state']; $propertyzip = $row['zip']; $active = $row['active']; $lease = $row['lease']; $leaseamt = $row['leaseamt']; if($active == "1"){ $propertystatus = "Active"; } else { $propertystatys = "Unknown"; } print"<tr onMouseOver=\"this.bgColor = '#CEE3F6'\" onMouseOut =\"this.bgColor = '#FFFFFF'\"> <td align=\"left\" width=\"25%\" onclick=\"window.open('viewpropdetail.php?prop=$propertyid','mywindow','width=1200,height=600,scrollbars=1')\">$propertyname</td><td>$ownerfirstname $ownerlastname</td><td>$propertystatus</td><td>$$leaseamt</td> "; } print"</td></table>"; ?> Basically i have a link under that is add property. it pops up a box. with a form you fill it out, and it inserts the record into database. What I'm trying to do. is get it to "Refresh" the property list ( ex. code above). so it shows the new property in the table. i have never used jQuery. but was wondering if i could do that with php. Is there a way to say if records are changed.. update? Hi All (Again) I am looking to pick up variables in jquery from a string created: function search_by() { var search_term = $('#search_for', $(this).attr('value')); alert(search_term); } I cant seem to get the value i am trying to into a "var". This is the code on the page i am using a onClick="search_by();" i.e: <a class="show_cats" search_cat="PDAs & Accessories" search_for="fire" onclick="search_by();" href="#"> I am trying to get the value inside the "search_for" field. Any ideas???? Alright guys, I have a bit of a problem here. I am deleting records using isset($_POST) on the current page but when it submits the records i deleted are still visible. I was thinking of echoing some jquery/ajax to re-load the div that displays the records. Has anyone ever done this before? I dont want the entire page to re-load just that specific area. Hi I am in the process of teaching myself web development, coming from a vb and mssql background. I am building a small page that will display my film library, I just want something quick and simple that gets things working. I have three img tags on my page that display the film posters. The current film and the one previous and next. What I would like is a left and a right arrow that just scroll through the library. I am thinking I need to read the sub folder of D:\movies and story the full path name into an array, and then when the user presses a arrow it moves forward or back. Everything is local and I am unsure about how to handle the event of the left/arrow being pressed. Does PHP handle that kind of event or would Jquery be more suitable or something else completely?? thanks for any pointers. Hey, I have a foreach loop displaying some data from my table, what i need to do is run a Jquery each function on the repeated element so it fadesIn each element one at a time. I am guessing i need to set somesort of interval for this to work. I have been messing with it for a good hour or so now and i cant seem to get it working. Has anyone done this before or seen it done else were? I keep saying I'm going to have to learn javascript and then the library jQuery but find myself learning Swift now instead.
Short one today. I want these two functions to occur back to back. Second function only begins after the first function is complete.
$(function() { $('.tlt').textillate(); }) $(function() { $('.tlt1').textillate(); })If you can please help me with this not only in just code to make that happen but also an explanation of what you did I sure would appreciate it. I've read all morning on promises etc. but have yet to be successful in implementing this. As you can tell I'm using the plug-in textillate to fade text out one letter at a time. Works great! But I have multiple paragraphs I'm wanting to apply this too so I can't make the div class .tlt since I then lose all paragraphs since it's strips it into spans. That would be ideal of course but I think I forced into making different classes for each paragraph. This will become problematic in the future though since the content is generated dynamically and I will have no idea how many paragraphs that dynamic content will contain. So if there was a way to keep my <p> and </p> that would be even better. Thanks! I am using jQuery to post the contents of a html form to a php file which process them then returns a result. jQuery then catches this result and either logs you in or displays an error. This is working fine. It logs me in if i specify the right details and doesnt if i specify wrong details. However when i am redirectd to the home page I have a line which says welcome {username}. However username displays an undefined. Here is the form(cut down) <form name="login_form" id="login_form" method="post"> <input id="user_name" class="field" type="text" name="user_name_field" /> </form> next is the jquery which posts the form data(cut down): jQuery("#login_form").submit(function() { jQuery.post("./modules/login_process.php",{ user_name:jQuery("#user_name").val() } ,function(data) { if (data == 1) { document.location="./index.php"; } else { } }); }); then is the login_process.php if (isset($_POST['user_name'])) { $user_name = asf_escape(trim($_POST['user_name'])); $login_query = mysql_query("SELECT * FROM ".TBL_PREFIX."members WHERE user_username = '$user_name' ") or die (mysql_error()); $result = mysql_num_rows($login_query); if ($result != 0) { $_SESSION['logged_in'] = 1; $_SESSION['user_username'] = $user_name; echo $result; } else { if(!empty($user_name)) { $error .= "No Records Found for Username: $user_name "; } echo $error; } As I said it works fine logging in, the username is checked against the database but when i return the session which is equal to the posted username i get "undefined". Anyone see where i am going wrong? I am trying to limit comments and replies to comments and display an error message once the limit is reached. I have successfully limited comments and comment replies, and successfully provided the error message when prompted ONLY for the comments, and not the comment replies. The comment replies have a little bit of jquery working with them, so that's the only thing I can see that would be causing the message not to display. I have tried other methods then the one currently being used. https://gist.github.com/8972a8343c6fd2b878b1 thanks in advance. This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=316223.0 I have a while loop fucntion displaying a list of records, each while records contains a hidden div with additional infomation and a button that will call JQuery slideToggle() function. each button on each record toggles alll the hidden divs. Does anyone have any ideas on how to sort this issue? Hello everyone, im make a website for my final school project. My header is a image slider made in jQuery with a time interval to change to images. At the moment when you press a link, the URL changes (example: index.php?page=contact). Then I use the $_GET to know what html file needs to be included, for this example: contact.html. The problem is when the URL changes (after clicking a link), the page refreshes and my jQuery header also refreshes to image[0]. Is there a way to include the right content when clicking on a link, without refreshing the page/header? Thanks in advance Gucco. This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=342757.0 |