Jump to content

harkly

Members
  • Posts

    264
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

harkly's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. I am attempting to use the croppic, http://www.jqueryrain.com/?S4PWDcPG, to modify images and want to be able to control the name of the file being produced. I also want to be able to save the name to my database. My quess is that I have to pass a variable to the img_save_to_file.php but not sure how to do that, I've tried using sessions but could not get that to work. Is there any other way that I could try but am not thinking of. A bit confused any direction would be appreciated. <?php /* * !!! THIS IS JUST AN EXAMPLE !!!, PLEASE USE ImageMagick or some other quality image processing libraries */ $imagePath = "temp/"; $allowedExts = array("gif", "jpeg", "jpg", "png", "GIF", "JPEG", "JPG", "PNG"); $temp = explode(".", $_FILES["img"]["name"]); $extension = end($temp); //Check write Access to Directory if(!is_writable($imagePath)){ $response = Array( "status" => 'error', "message" => 'Can`t upload File; no write Access' ); print json_encode($response); return; } if ( in_array($extension, $allowedExts)) { if ($_FILES["img"]["error"] > 0) { $response = array( "status" => 'error', "message" => 'ERROR Return Code: '. $_FILES["img"]["error"], ); } else { $filename = $_FILES["img"]["tmp_name"]; list($width, $height) = getimagesize( $filename ); move_uploaded_file($filename, $imagePath . $_FILES["img"]["name"]); $response = array( "status" => 'success', "url" => $imagePath.$_FILES["img"]["name"], "width" => $width, "height" => $height ); } } else { $response = array( "status" => 'error', "message" => 'something went wrong, most likely file is to large for upload. check upload_max_filesize, post_max_size and memory_limit in you php.ini', ); } print json_encode($response); ?>
  2. Edit: upload blob not blog I would like to use the following code to crop images that will be uploaded to mySql with PHP. I just cannot figure out how to call the blob so I can use it. Can someone help me with this? Using the code from here: http://hongkhanh.github.io/cropbox/ HTML <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>Crop Box</title> <link rel="stylesheet" href="style.css" type="text/css" /> <style> .container { position: absolute; top: 10%; left: 10%; right: 0; bottom: 0; } .action { width: 400px; height: 30px; margin: 10px 0; } .cropped>img { margin-right: 10px; border:1px solid green: } </style> </head> <body> <script src="../cropbox.js"></script> <div class="container"> <div class="imageBox"> <div class="thumbBox"></div> <div class="spinner" style="display: none">Loading...</div> </div> <div class="action"> <input type="file" id="file" style="float:left; width: 250px"> <input type="button" id="btnCrop" value="Crop" style="float: right"> <input type="button" id="btnZoomIn" value="+" style="float: right"> <input type="button" id="btnZoomOut" value="-" style="float: right"> </div> <div class="cropped"></div> <script type="text/javascript"> window.onload = function() { var options = { imageBox: '.imageBox', thumbBox: '.thumbBox', spinner: '.spinner', imgSrc: 'avatar.png' } var cropper = new cropbox(options); document.querySelector('#file').addEventListener('change', function(){ var reader = new FileReader(); reader.onload = function(e) { options.imgSrc = e.target.result; cropper = new cropbox(options); } reader.readAsDataURL(this.files[0]); this.files = []; }) document.querySelector('#btnCrop').addEventListener('click', function(){ var img = cropper.getDataURL(); document.querySelector('.cropped').innerHTML += '<img src="'+img+'">'; }) document.querySelector('#btnZoomIn').addEventListener('click', function(){ cropper.zoomIn(); }) document.querySelector('#btnZoomOut').addEventListener('click', function(){ cropper.zoomOut(); }) }; </script> </body> </html> /** * Created by ezgoing on 14/9/2014. */ 'use strict'; var cropbox = function(options){ var el = document.querySelector(options.imageBox), obj = { state : {}, ratio : 1, options : options, imageBox : el, thumbBox : el.querySelector(options.thumbBox), spinner : el.querySelector(options.spinner), image : new Image(), getDataURL: function () { var width = this.thumbBox.clientWidth, height = this.thumbBox.clientHeight, canvas = document.createElement("canvas"), dim = el.style.backgroundPosition.split(' '), size = el.style.backgroundSize.split(' '), dx = parseInt(dim[0]) - el.clientWidth/2 + width/2, dy = parseInt(dim[1]) - el.clientHeight/2 + height/2, dw = parseInt(size[0]), dh = parseInt(size[1]), sh = parseInt(this.image.height), sw = parseInt(this.image.width); canvas.width = width; canvas.height = height; var context = canvas.getContext("2d"); context.drawImage(this.image, 0, 0, sw, sh, dx, dy, dw, dh); var imageData = canvas.toDataURL('image/png'); return imageData; }, getBlob: function() { var imageData = this.getDataURL(); var b64 = imageData.replace('data:image/png;base64,',''); var binary = atob(b64); var array = []; for (var i = 0; i < binary.length; i++) { array.push(binary.charCodeAt(i)); } return new Blob([new Uint8Array(array)], {type: 'image/png'}); }, zoomIn: function () { this.ratio*=1.1; setBackground(); }, zoomOut: function () { this.ratio*=0.9; setBackground(); } }, attachEvent = function(node, event, cb) { if (node.attachEvent) node.attachEvent('on'+event, cb); else if (node.addEventListener) node.addEventListener(event, cb); }, detachEvent = function(node, event, cb) { if(node.detachEvent) { node.detachEvent('on'+event, cb); } else if(node.removeEventListener) { node.removeEventListener(event, render); } }, stopEvent = function (e) { if(window.event) e.cancelBubble = true; else e.stopImmediatePropagation(); }, setBackground = function() { var w = parseInt(obj.image.width)*obj.ratio; var h = parseInt(obj.image.height)*obj.ratio; var pw = (el.clientWidth - w) / 2; var ph = (el.clientHeight - h) / 2; el.setAttribute('style', 'background-image: url(' + obj.image.src + '); ' + 'background-size: ' + w +'px ' + h + 'px; ' + 'background-position: ' + pw + 'px ' + ph + 'px; ' + 'background-repeat: no-repeat'); }, imgMouseDown = function(e) { stopEvent(e); obj.state.dragable = true; obj.state.mouseX = e.clientX; obj.state.mouseY = e.clientY; }, imgMouseMove = function(e) { stopEvent(e); if (obj.state.dragable) { var x = e.clientX - obj.state.mouseX; var y = e.clientY - obj.state.mouseY; var bg = el.style.backgroundPosition.split(' '); var bgX = x + parseInt(bg[0]); var bgY = y + parseInt(bg[1]); el.style.backgroundPosition = bgX +'px ' + bgY + 'px'; obj.state.mouseX = e.clientX; obj.state.mouseY = e.clientY; } }, imgMouseUp = function(e) { stopEvent(e); obj.state.dragable = false; }, zoomImage = function(e) { var evt=window.event || e; var delta=evt.detail? evt.detail*(-120) : evt.wheelDelta; delta > -120 ? obj.ratio*=1.1 : obj.ratio*=0.9; setBackground(); } obj.spinner.style.display = 'block'; obj.image.onload = function() { obj.spinner.style.display = 'none'; setBackground(); attachEvent(el, 'mousedown', imgMouseDown); attachEvent(el, 'mousemove', imgMouseMove); attachEvent(document.body, 'mouseup', imgMouseUp); var mousewheel = (/Firefox/i.test(navigator.userAgent))? 'DOMMouseScroll' : 'mousewheel'; attachEvent(el, mousewheel, zoomImage); }; obj.image.src = options.imgSrc; attachEvent(el, 'DOMNodeRemoved', function(){detachEvent(document.body, 'DOMNodeRemoved', imgMouseUp)}); return obj; };
  3. What I don't understand if that it was all working fine before last Friday and then nothing. It won't send to any email account I have people from different ones trying it and nothing as long as it has the wlsingles.com url in it even if its an email address from there won't work $headers = 'From: WLSingles <email@WLSingles.com>' ; So say it is got listed somewhere what do I do?? Start all over again?? A different domain name?? So ready to tear my hair out!
  4. I am trying this code out on 2 different servers and it definity stops when I enter the one particular url - how do I check why?
  5. I using this simple code to send a test message if I put in my url it won't send, more like it sends but never gets received no matter what email account I use. If I put in another url it works fine. Does anyone know what causes that and how I can go about fixing it?? in this code I added a '2' to the url and it works, take the 2 out - nothing <?php mail('me@yahoo.com', 'Account Info', 'is this working? www.wlsingle2s.com');?>
  6. That's where I am getting a bit confused. All my code works and I am not getting any MySql errors and any fields that require user input are handled within that code. I wasn't going to put any error handling other then not to show but everything I read tells me I need to
  7. So I should handle them in each and every Select, Update ...?
  8. I have a site that is going to go public and I am wondering what is the status quo on handling possible errors? I have them turned off so they won't show and they will be sent to an email but what about on the user end? What should I have happen so the user won't get confused??? This is probably a stupid question but is there a way to check the page for an over-all-error vs putting an error check in every Select & Update? What I would like to do, if possilbe: page opens - there is an error - kicks user to a new page - emails error to me. I have it all working just wondering if I can do some generic check and then execute everything.
  9. Never mind I got it Not sure if this is a regex issue or a preg_match code issue Have this function and I cannot use the @ or the % in a new password function newPswdChar($newPswd) { if (preg_match('/^[a-z0-9@!#%]+$/i',$newPswd)) return FALSE; else return TRUE; } But goes thru the Javascript check fine var alphaExpression = /^[a-z0-9@!%#]+$/i; if(!form.newPswd.value.match(alphaExpression)) { alert("Error: Invalid characters where used!"); form.newPswd.focus(); return false; } I just want to allow letters, numbers and @ ! % #. I looked and looked at the regex stuff and it seems to point to me having it correct. Can someone help me with this?
  10. Thanks! New there was something, Googling the wrong terms
  11. I have limited the upload size in my php.ini but I want a message for the user so they no that the size was to large. Is there anyway to do this?
  12. When dealing with numbers do I need to implement all the security? On in-putting into my DB I have all numbers validating, with a case statement, and I use prepared statements. So when pulling number data do I need to sanitize it as well? The types are smallint() or tinyint()
  13. Also have one more question I am using mysqli! and then filtering the data on input do I really need to escape it as well? I ask this becuase when escaping it is messing up the format of the text when there is a break in it.
×
×
  • 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.