PHP - How To Crop The Image Using Native Php?
There is a picture with dimensions of 10000 by 10000 pixels. Need to display a picture with dimensions of 200 by 100. Only need to use native php. Similar TutorialsHello everyone, In fact, I have a script that makes the crop image that works well, I'm stuck on the part of adding a text box to allow to name the image "thumb". I also ask if possible to remove the "PHP_SELF" script and divide it into several pages. Attached script I want to reduce a picture size from 600px * 500px to 60px * 50px size, then crop it become 50px *50px. I have two groups of codes, 1 is to reduce the size of image, other 1 is to crop the image. The problem is they works separately, how to combine this two groups of codes to make them work together? Below is my codes : Code: [Select] <?php //codes of group A - Reduce the size of image from 600px * 500px to 60px * 50px $save2 = "images/users/" . $image_name_2; //This is the new file you saving list($width2, $height2) = getimagesize($file) ; $modwidth2 = 50; $diff2 = $width2 / $modwidth2; $modheight2 = $height2 / $diff2; $tn2 = imagecreatetruecolor($modwidth2, $modheight2) ; $image2 = imagecreatefromjpeg($file) ; imagecopyresampled($tn2, $image2, 0, 0, 0, 0, $modwidth2, $modheight2, $width2, $height2) ; imagejpeg($tn2, $save2, 100) ; //codes of group B - Crop the image from 60px * 50px to 50px * 50px $save3 = "images/users/" . $image_name_3; list($width3, $height3) = getimagesize($file) ; $modwidth3 = 60; $diff3 = $width3 / $modwidth3; $modheight3 = $height3 / $diff3; $left = 0; $top = 0; $cropwidth = 50; //thumb size $cropheight = 50; $tn3 = imagecreatetruecolor($cropwidth, $cropheight) ; $image3 = imagecreatefromjpeg($file) ; imagecopyresampled($tn3, $image3, 0, 0, $left, $top, $cropwidth, $cropheight, $modwidth3, $modheight3) ; imagejpeg($tn3, $save3, 100) ; //save the cropped image ?> As you can see from 2 groups of codes above, 1st group resize the pic then save it to a folder. 2nd group of codes crop the pic then save it into the folder too. My question is ... After 1st group of codes resize the picture, is it necessary to save it into folder before I can crop it? If it is necessary, then I need to write new lines of codes to retrieve the resized pic from the folder for 2nd group of codes to crop it? If it is not necessary, after resizing the pic, how do I pass the pic to 2nd group of codes to crop it? php image-resizing I'll explain with an example: I have this image: http://www.fitnessvital.com/images/galeria/caballo-pastando-0.jpg I create a thumbnail of it: http://www.fitnessvital.com/images/galeria/thumbs/caballo-pastando-0.jpg You can see that it's a big image where the important thing is the horse. The grass is not important. So, the best thing to do it's to crop the extra grass and resizing the rest. So the question is: There's a way of recognizing the objects of an image and crop the rest ? Or identify the non important of an imagen and cropt it ? (the same rewrited) Thank you I've been creating my own image upload script which takes in several parameters to style an image, however when the function is used new width and new height are specified but I need to use these values to determine cropping coordinates. What I want is when a new width and height is specified, if it is squared i.e. new width is equal to new height AND the original image is not squared i.e. it is a vertical or horizontal rectangle then the central part of that image will be taken. So for example if the user uploads an image 500px high and 100px wide and sets the new width and height both at 100px the new image should be a 100px by 100px square which is taken 200px from the top of the original image. Here is the functions I currently use so far. It's just the coordinates function I can't seem to figure out. Can anyone please help me out:- Code: [Select] //gets the extension of an uploaded file function getExtension($file) { $i = strrpos($file,".");//Gets the position of the "." in the filename if (!$i) { return ""; }//If there is no "." the function ends and returns "" $l = strlen($file) - $i; $ext = substr($file,$i+1,$l); $ext = strtolower($ext); return $ext; } //checks image dimensions and scales both sizes by ratio if it exceeds the max //$w = width, $mw = max width, $h = height, $mh = max height, function checkSize($w, $mw, $h, $mh){ if($w > $mw){//Checks if width is greater than max width $ratio = $mw / $w; $h = $h * $ratio; $h = round($h); $w = $mw; } if($h > $mh){//Checks if height is greater than max height $ratio = $mh / $h; $w = $w * $ratio; $w = round($w); $h = $mh; } return array($w, $h); } //Used to get the coordinates to resize an image by function getCoords(){ } //$f = the file, $ext = file extension, $nw = new width, $nh = new height, $mw = max width, $mh = max height, $nf = new filename, $fo = folder, $des = file size description, $q = quality function imageUpload($f, $ext, $nw, $nh, $mw, $mh, $nf, $fo, $des, $q){ //create image from uploaded file type if($ext=="jpg" || $ext=="jpeg" ){ $src = imagecreatefromjpeg($f); }else if($ext=="png"){ $src = imagecreatefrompng($f); }else{ $src = imagecreatefromgif($f); } //creates a list of the width and height of the image list($w,$h)=getimagesize($f); //sets the coordinates for resizing to 0 by default $dx = $dy = $sx = $sy = 0; //if new width and height are both 0 then a resize is not required so original dimensions need to be validated in case they exceed their max if($nw == 0 && $nh == 0){ if($w > $mw || $h > $mh){//checks if width or height are greater than their max list($w, $h) = checkSize($w, $mw, $h, $mh); } $nw = $w; $nh = $h; }else if($nw == $nh && $w !== $h){//this is for if the resized image needs to be squared but the original image is not a square //COORDS FUNCTION NEEDED HERE } $desext = "";//sets the description extension to "" by default if($des !== 0){//Checks if $des is set or not $desext .= "_".$des;//appends des to $desext ready to be appended to the filename } $foext = "";//sets the folder extension to "" by default if($fo !== 0){//Checks if $fo is set or not $foext .= $fo."/";//appends folder to $foext ready to be appended to the filename } $qv = 100;//sets the quality value to 100 percent by default if($q !== 0){//Checks if $q is set or not $qv .= $q;//sets the quality value to the passed value } $tmp=imagecreatetruecolor($nw,$nh); imagecopyresampled($tmp,$src,$dx,$dy,$sx,$sy,$nw,$nh,$w,$h); $fn = "images/".$foext.$nf.$desext.".jpg";//sets the final filename for upload imagejpeg($tmp,$fn,$qv);//uploads the file //empty variables and clear image imagedestroy($src); imagedestroy($tmp); } i have this awesome script i've used on multiple websites and only now is it giving me trouble. it's always aligned/cropped to the middle of the image but for some reason the smaller thumbnails are cropping to the bottom. Code: [Select] <?php header ("Content-type: image/jpeg"); $file_name=$_GET['f']; $crop_height=$_GET['h']; $crop_width=$_GET['w']; $file_type= explode('.', $file_name); $file_type = $file_type[count($file_type) -1]; $file_type=strtolower($file_type); $original_image_size = getimagesize($file_name); $original_width = $original_image_size[0]; $original_height = $original_image_size[0]; if($file_type=='jpg') { $original_image_gd = imagecreatefromjpeg($file_name); } if($file_type=='gif') { $original_image_gd = imagecreatefromgif($file_name); } if($file_type=='png') { $original_image_gd = imagecreatefrompng($file_name); } $cropped_image_gd = imagecreatetruecolor($crop_width, $crop_height); $wm = $original_width /$crop_width; $hm = $original_height /$crop_height; $h_height = $crop_height/2; $w_height = $crop_width/2; if($original_width > $original_height ) { $adjusted_width =$original_width / $hm; $half_width = $adjusted_width / 2; $int_width = $half_width - $w_height; imagecopyresampled($cropped_image_gd ,$original_image_gd ,-$int_width,0,0,0, $adjusted_width, $crop_height, $original_width , $original_height ); } elseif(($original_width < $original_height ) || ($original_width == $original_height )) { $adjusted_height = $original_height / $wm; $half_height = $adjusted_height / 2; $int_height = $half_height - $h_height; imagecopyresampled($cropped_image_gd , $original_image_gd ,0,-$int_height,0,0, $crop_width, $adjusted_height, $original_width , $original_height ); } else { imagecopyresampled($cropped_image_gd , $original_image_gd ,0,0,0,0, $crop_width, $crop_height, $original_width , $original_height ); } imagejpeg($cropped_image_gd); ?> if i modify the value of original_image_size, it crops to the middle, but if the height is greater than the width it will add black on either side of the image to fill out the designated value. Code: [Select] $original_image_size = getimagesize($file_name); $original_width = $original_image_size[0]; $original_height = $original_image_size[1]; i can't figure out how to get it do both. 0, 0 outputs this: http://www.loudtechinc.com/images/scriptissue/00.png http://www.loudtechinc.com/images/scriptissue/00n2.png 0, 1 outputs this: http://www.loudtechinc.com/images/scriptissue/01.png http://www.loudtechinc.com/images/scriptissue/01n2.png The end goal is to have it fill the desired height and width while cropping to the middle. Hey all
I have been building sites for a long time and I am pretty confident in modern frameworks like Bootstrap etc. I have played about with JQuery Mobile and UI. I know how to make mobile sites from a front end side. I understand that I can upload my site to PhoneGap and turn it into a native app.
However, I would love to know how to make useful apps that dont just display static text. E.g. using things like Google Places API.
I know how to make mobile sites easily enough that display info. I just don't really understand how to link that up with dynamic data from APIs etc. How to feed that content back to the user.
For a vasic example, say I wanted to have a simple app that had a search box. You enter 'PIZZA' into it and it comes back with a result of all local pizza spots. How would I do that?
If someone could point me in the right direction for where I could experiment with this I would be really grateful . Hi I want to build a script in php that take from user an image and split(crop) the image to 8 or 12 parts equal in the size for puzzel. my problem is how to crope the image to some number 8? I have a link for libery name phpthumb the adress is : http://phpthumb.gxdlabs.com/ In the libery there is a folder examples/crop_basic.php the file crop_basic.php do the missuen but only for one part is crop I dont know how to crop more then one Can you help me please thanks Hello, My current server setup :
PHP version: 7.1.4
From what I read, in order to have MySQL return native datatypes (as opposed to just strings) : Now, I do have mysqlnd, but a simple PDO Prepared statement still returns me all strings, even though some columns are set as INT, VARCHAR, DATETIME, etc.. $stmt = $pdo->prepare("SELECT * FROM tbl_users WHERE id=1"); $stmt->execute(); $user = $stmt->fetch(); var_dump($user); OUTPUT: array(13) { ["id"]=> string(1) "1" ["is_admin"]=> string(1) "1" ["is_active"]=> string(1) "1" ["username"]=> string(5) "jdoe" ... }
I'm not sure what to look for to resolve this issue if I want it to return INT as INT and not STRING, etc. Does having `extension_loaded('mysqlnd') == true`, make my system automatically use this native mysql driver? How can I tell ? Could this be a version problem perhaps?
Much thanks! Pat
I need to set the width and let height adjust to the proportions of width. Can someone please help me with this? I understand that $canvas_height should be 160, but then the image will crop to whichever side is greatest not by the width only. Code: [Select] <?php $img = "image.jpg"; $canvas_width = 160; $canvas_height = 0; list($img_width, $img_height) = getimagesize($img); $ratio_orig = $img_width / $img_height; if($canvas_width / $canvas_height > $ratio_orig) { $canvas_width = $canvas_height * $ratio_orig; } else { $canvas_height = $canvas_width / $ratio_orig; } $original = imagecreatefromjpeg($img); $canvas = imagecreatetruecolor($canvas_width, $canvas_height); imagecopyresampled($canvas, $original, 0, 0, 0, 0, $canvas_width, $canvas_height, $img_width, $img_height); $dest = "medium/image.jpg"; imagejpeg($canvas, $dest, 100); ?> good day dear community, this is a big issue. I have to decide: between native PHP DOM Extension or of simple DOM html parser well i want to parse the site he http://buergerstiftungen.de/cps/rde/xchg/SID-A7DCD0D1-702CE0FA/buergerstiftungen/hs.xsl/db.htm http://buergerstiftungen.de/cps/rde/xchg/SID-A7DCD0D1-702CE0FA/buergerstiftungen/hs.xsl/db.htm I will suggest to use the native PHP "DOM" Extension instead of "simple html parser", since it will be much faster and easier What do you think about this one here...: Code: [Select] $doc = new DOMDocument @$doc->loadHTMLFile('...URL....'); // Using the @ operator to hide parse errors $contents = $doc->getElementById('content')->nodeValue; // Text contents of #content look forward to hear from you best regards db1 This topic has been Ctrl+X/Ctrl+V'd to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=347400.0 How can i edit just one image at on time with a multiple image upload form? I have the images being stored in a folder and the path being stored in MySQL. I also have the files being uploaded with a unique id. My issue is that I want to be able to pass the values of what is already in $name2 $name3 $name4 if I only want to edit $name1. I don't want to have to manually update the 4 images. Here is the PHP: Code: [Select] <?php require_once('storescripts/connect.php'); mysql_select_db($database_phpimage,$phpimage); $uploadDir = 'upload/'; if(isset($_POST['upload'])) { foreach ($_FILES as $file) { $fileName = $file['name']; $tmpName = $file['tmp_name']; $fileSize = $file['size']; $fileType = $file['type']; if ($fileName != ""){ $filePath = $uploadDir; $fileName = str_replace(" ", "_", $fileName); //Split the name into the base name and extension $pathInfo = pathinfo($fileName); $fileName_base = $pathInfo['fileName']; $fileName_ext = $pathInfo['extension']; //now we re-assemble the file name, sticking the output of uniqid into it //and keep doing this in a loop until we generate a name that //does not already exist (most likely we will get that first try) do { $fileName = $fileName_base . uniqid() . '.' . $fileName_ext; } while (file_exists($filePath.$fileName)); $file_names [] = $fileName; $result = move_uploaded_file($tmpName, $filePath.$fileName); } if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $fileinsert[] = $filePath; } } $mid = mysql_real_escape_string(trim($_POST['mid'])); $cat = mysql_real_escape_string(trim($_POST['cat'])); $item = mysql_real_escape_string(trim($_POST['item'])); $price = mysql_real_escape_string(trim($_POST['price'])); $about = mysql_real_escape_string(trim($_POST['about'])); $fields = array(); $values = array(); $updateVals = array(); for($i = 0; $i < 4; $i++) { $values[$i] = isset($file_names[$i]) ? mysql_real_escape_string($file_names[$i]) : ''; if($values[$i] != '') { $updateVals[] = 'name' . ($i + 1) . " = '{$values[$i]}'"; } } $updateNames = ''; if(count($updateVals)) { $updateNames = ", " . implode(', ', $updateVals); } $update = "INSERT INTO image (mid, cid, item, price, about, name1, name2, name3, name4) VALUES ('$mid', '$cat', '$item', '$price', '$about', '$values[0]', '$values[1]', '$values[2]', '$values[3]') ON DUPLICATE KEY UPDATE cid = '$cat', item = '$item', price = '$price', about = '$about' $updateNames"; $result = mysql_query($update) or die (mysql_error()); Hi, I've read a lot of places that it's not recommended to store binary files in my db. So instead I'm supposed to upload the image to a directory, and store the link to that directory in database. First, how would I make a form that uploads the picture to the directory (And what kinda directories are we talking?). Secondly, how would I retrieve that link? And I guess I should rename the picture.. I'd appreciate any help, or a good tutorial (Haven't found any myself). The script for creating a new file name for the image:
$validextensions = array("jpeg", "jpg", "png"); //Extensions which are allowed $ext = explode('.', basename($_FILES['file']['name'][$i]));//explode file name from dot(.) $file_extension = end($ext); //store extensions in the variable $new_image_name = md5(uniqid()) . "." . $ext[count($ext) - 1]; $target_path = $target_path . $new_image_name;//set the target path with a new name of imageThe script creates a new file like: f6c9b8d9db05366c3504210cded9ddb2.jpgand moves the file to the "uploads" folder. And then the script also creates a thumbnail with the same file name and moves the file to the "thumbs" folder. The issue I am having is that the same ID code could happen again for a different image in the database, thus I would be calling a different original sized image than the thumbnail image. My question is: How to avoid this issue of the same ID code has happened again for a different file. What is the proper way to reference the anchor tag of the thumbnail image to its actual original sized image? With the script I have the thumbnail image would be coming from the "thumbs" folder and the anchor tag would get referenced to the "uploads" folder to get the original sized image. Edited by glassfish, 12 October 2014 - 05:51 AM. After image is drop into container , I want to move copy of the original image to be move when original image dragend within container. I tried but it display copy image each time when original image dragend. can anyone help me?
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Prototype</title> <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script> <script src="http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.7.2.min.js"></script> <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.min.js"></script> <style> body{padding:20px;} #container{ border:solid 1px #ccc; margin-top: 10px; width:350px; height:350px; } #toolbar{ width:350px; height:35px; border:solid 1px blue; } </style> <script> $(function(){ var $house=$("#house"); $house.hide(); var $stageContainer=$("#container"); var stageOffset=$stageContainer.offset(); var offsetX=stageOffset.left; var offsetY=stageOffset.top; var stage = new Kinetic.Stage({ container: 'container', width: 350, height: 350 }); var layer = new Kinetic.Layer(); stage.add(layer); var image1=new Image(); image1.onload=function(){ $house.show(); } image1.src="http://vignette1.wikia.nocookie.net/angrybirds/images/b/b6/Small.png/revision/latest?cb=20120501022157"; $house.draggable({ helper:'clone', }); $house.data("url","house.png"); // key-value pair $house.data("width","32"); // key-value pair $house.data("height","33"); // key-value pair $house.data("image",image1); // key-value pair $stageContainer.droppable({ drop:dragDrop, }); function dragDrop(e,ui){ var x=parseInt(ui.offset.left-offsetX); var y=parseInt(ui.offset.top-offsetY); var element=ui.draggable; var data=element.data("url"); var theImage=element.data("image"); var image = new Kinetic.Image({ name:data, x:x, y:y, image:theImage, draggable: true, dragBoundFunc: function(pos) { return { x: pos.x, y: this.getAbsolutePosition().y } } }); image.on("dragend", function(e) { var points = image.getPosition(); var image1 = new Kinetic.Image({ name: data, id: "imageantry", x: points.x+65, y: points.y, image: theImage, draggable: false }); layer.add(image1); layer.draw(); }); image.on('dblclick', function() { image.remove(); layer.draw(); }); layer.add(image); layer.draw(); } }); // end $(function(){}); </script> </head> <body> <div id="toolbar"> <img id="house" width=32 height=32 src="http://vignette1.wikia.nocookie.net/angrybirds/images/b/b6/Small.png/revision/latest?cb=20120501022157"><br> </div> <div id="container"></div> </body> </html> Edited by Biruntha, 08 January 2015 - 10:14 AM. Hello I am having problems uploading an image through a HTML form. I want the image to be uploaded to the server and the image name to be written to the mysql database. Below is the code I am using: Code: [Select] <?php if (isset($_POST['add'])){ echo "<br /> add value is true"; $name = $_POST['name']; $description = $_POST['description']; $price = $_POST['price']; $category_id = $_POST['category_name']; $image = $_FILES['image']['name']; //file path of the image upload $filepath = "../images/"; //mew name for the image upload $newimagename = $name; //new width for the image $newwidth = 100; //new height for the image $newheight = 100; include('../includes/image-upload.php'); mysql_query("INSERT INTO item (item_name, item_description, item_price, item_image) VALUES ('$name','$description','$price','$image')"); ?> Here is the image-upload.php file code: Code: [Select] <?php //assigns the file to the image $image =$_FILES["image"]["name"]; $uploadedfile =$_FILES["image"]["tmp_name"]; if ($image) { //retrieves the extension type from image upload $extension = getextension($image); //converts extension to lowercase $extension = strtolower($extension); //create image from uploaded file type if($extension=="jpg" || $extension=="jpeg") { $uploadedfile = $_FILES['image']['tmp_name']; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png") { $uploadedfile = $_FILES['image']['tmp_name']; $src = imagecreatefrompng($uploadedfile); }else{ $src = imagecreatefromgif($uploadedfile); } //creates a list of the width and height of the image list($width,$height)=getimagesize($uploadedfile); //adds color to the image $tmp = imagecreatetruecolor($newwidth,$newheight); //create image imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); //set file name $filename = $filepath.$newimagename.".".$extension; $imagename = $newimagename.".".$extension; //uploads new file with name to the chosen directory imagejpeg($tmp,$filename,100); //empty variables imagedestroy($src); imagedestroy($tmp); } ?> Any help would be appreciated, fairly new to all this! Thanks!!! Can I get some help or a point in the right direction.
I am trying to create a form that allows me to add, edit and delete records from a database.
I can add, edit and delete if I dont include the image upload code.
If I include the upload code I cant edit records without having to upload the the same image to make the record save to the database.
So I can tell I have got the code processing in the wrong way, thing is I cant seem to see or grasp the flow of this, to make the corrections I need it work.
Any help would be great!
Here is the form add.php code
<?php require_once ("dbconnection.php"); $id=""; $venue_name=""; $address=""; $city=""; $post_code=""; $country_code=""; $url=""; $email=""; $description=""; $img_url=""; $tags=""; if(isset($_GET['id'])){ $id = $_GET['id']; $sqlLoader="Select from venue where id=?"; $resLoader=$db->prepare($sqlLoader); $resLoader->execute(array($id)); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Add Venue Page</title> <link href='http://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <?php $sqladd="Select * from venue where id=?"; $resadd=$db->prepare($sqladd); $resadd->execute(array($id)); while($rowadd = $resadd->fetch(PDO::FETCH_ASSOC)){ $v_id=$rowadd['id']; $venue_name=$rowadd['venue_name']; $address=$rowadd['address']; $city=$rowadd['city']; $post_code=$rowadd['post_code']; $country_code=$rowadd['country_code']; $url=$rowadd['url']; $email=$rowadd['email']; $description=$rowadd['description']; $img_url=$rowadd['img_url']; $tags=$rowadd['tags']; } ?> <h1 class="edit-venue-title">Add Venue:</h1> <form role="form" enctype="multipart/form-data" method="post" name="formVenue" action="save.php"> <input type="hidden" name="id" value="<?php echo $id; ?>"/> <div class="form-group"> <input class="form-control" type="hidden" name="id" value="<?php echo $id; ?>"/> <p><strong>ID:</strong> <?php echo $id; ?></p> <strong>Venue Name: *</strong> <input class="form-control" type="text" name="venue_name" value="<?php echo $venue_name; ?>"/><br/> <br/> <strong>Address: *</strong> <input class="form-control" type="text" name="address" value="<?php echo $address; ?>"/><br/> <br/> <strong>City: *</strong> <input class="form-control" type="text" name="city" value="<?php echo $city; ?>"/><br/> <br/> <strong>Post Code: *</strong> <input class="form-control" type="text" name="post_code" value="<?php echo $post_code; ?>"/><br/> <br/> <strong>Country Code: *</strong> <input class="form-control" type="text" name="country_code" value="<?php echo $country_code; ?>"/><br/> <br/> <strong>URL: *</strong> <input class="form-control" type="text" name="url" value="<?php echo $url; ?>"/><br/> <br/> <strong>Email: *</strong> <input class="form-control" type="email" name="email" value="<?php echo $email; ?>"/><br/> <br/> <strong>Description: *</strong> <textarea class="form-control" type="text" name="description" rows ="7" value=""><?php echo $description; ?></textarea><br/> <br/> <strong>Image Upload: *</strong> <input class="form-control" type="file" name="image" value="<?php echo $img_url; ?>"/> <small>File sizes 300kb's and below 500px height and width.<br/><strong>Image is required or data will not save.</strong></small> <br/><br/> <strong>Tags: *</strong> <input class="form-control" type="text" name="tags" value="<?php echo $tags; ?>"/><small>comma seperated vales only, e.g. soul,hip-hop,reggae</small><br/> <br/> <p>* Required</p> <br/> <input class="btn btn-primary" type="submit" name="submit" value="Save"> </div> </form> </div> </body> </html>Here is the save.php code <?php error_reporting(E_ALL); ini_set("display_errors", 1); include ("dbconnection.php"); $venue_name=$_POST['venue_name']; $address=$_POST['address']; $city=$_POST['city']; $post_code=$_POST['post_code']; $country_code=$_POST['country_code']; $url=$_POST['url']; $email=$_POST['email']; $description=$_POST['description']; $tags=$_POST['tags']; $id=$_POST['id']; if(is_uploaded_file($_FILES['image']['tmp_name'])){ $folder = "images/hs-venues/"; $file = basename( $_FILES['image']['name']); $full_path = $folder.$file; if(move_uploaded_file($_FILES['image']['tmp_name'], $full_path)) { //echo "succesful upload, we have an image!"; var_dump($_POST); if($id==null){ $sql="INSERT INTO venue(venue_name,address,city,post_code,country_code,url,email,description,img_url,tags)values(:venue_name,:address,:city,:post_code,:country_code,:url,:email,:description,:img_url,:tags)"; $qry=$db->prepare($sql); $qry->execute(array(':venue_name'=>$venue_name,':address'=>$address,':city'=>$city,':post_code'=>$post_code,':country_code'=>$country_code,':url'=>$url,':email'=>$email,':description'=>$description,':img_url'=>$full_path,':tags'=>$tags)); }else{ $sql="UPDATE venue SET venue_name=?, address=?, city=?, post_code=?, country_code=?, url=?, email=?, description=?, img_url=?, tags=? where id=?"; $qry=$db->prepare($sql); $qry->execute(array($venue_name, $address, $city, $post_code, $country_code, $url, $email, $description, $full_path, $tags, $id)); } if($success){ var_dump($_POST); echo "<script language='javascript' type='text/javascript'>alert('Successfully Saved!')</script>"; echo "<script language='javascript' type='text/javascript'>window.open('index.php','_self')</script>"; } else{ var_dump($_POST); echo "<script language='javascript' type='text/javascript'>alert('Successfully Saved!')</script>"; echo "<script language='javascript' type='text/javascript'>window.open('index.php','_self')</script>"; } } //if uploaded else{ var_dump($_POST); echo "<script language='javascript' type='text/javascript'>alert('Upload Recieved but Processed Failed!')</script>"; echo "<script language='javascript' type='text/javascript'>window.open('index.php','_self')</script>"; } } //move uploaded else{ var_dump($_POST); echo "<script language='javascript' type='text/javascript'>alert('Successfully Updated.')</script>"; echo "<script language='javascript' type='text/javascript'>window.open('index.php','_self')</script>"; } ?>Thanks in advance! Edited by hankmoody, 12 August 2014 - 05:15 PM. Hello, I've had success creating a cool vanity QR code with rounded edges for my organization by generating a standard QR code, then applying a noise -> median effect in Photoshop to get the edges rounded among some other effects. Photoshop is great, but I want to automate this. I found a great PHP library to generate QR codes. The part I don't get is the rounding of the hard edges. I've seen other sites do it like this one. So far google searches are yielding rounded corner tutorials. Any thoughts on how to do this with GD or ImageMagic? Best regards, Chris This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=351137.0 Hello, Five images will be displayed inside a division. There will be a previous and next button/link. If someone click the next button the next image will be added in that div and the first image will be gone from that div. The previous button/link will do the same thing. Is it possible with php? I am confused if it's a javascript or ajax question. Thanks. |