PHP - Correct Way To Com,press Jpg With Gd Library
Hello, what's the correct use of GD library to compress JPG images please? I am using this upload script with TinyMCE. See below : I have this snippet but it doesn't compress the image: // Accept upload if there was no origin, or if it is an accepted origin // If image is JPEG compress with GD library $filetowrite = $imageFolder . $temp['name']; if (in_array(strtolower(pathinfo($temp['name'], PATHINFO_EXTENSION)), array("jpg", "jpeg"))) { imagejpeg($temp['tmp_name'], $filetowrite, 75); } else { move_uploaded_file($temp['tmp_name'], $filetowrite); } <?php $accepted_origins = array("http://localhost", "http://127.0.0.1", "http://192.168.1.1", "http://example.com"); $month = strtolower(date('M')); $year = date('Y'); $newspath = "img/news/"; if (!is_dir("$newspath/$year/$month")) { mkdir("$newspath/$year/$month", 0777, true); } $imageFolder = "$newspath/$year/$month/"; reset ($_FILES); $temp = current($_FILES); if (is_uploaded_file($temp['tmp_name'])){ if (isset($_SERVER['HTTP_ORIGIN'])) { // same-origin requests won't set an origin. If the origin is set, it must be valid. if (in_array($_SERVER['HTTP_ORIGIN'], $accepted_origins)) { header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']); } else { header("HTTP/1.1 403 Origin Denied"); return; } } /* If your script needs to receive cookies, set images_upload_credentials : true in the configuration and enable the following two headers. */ // header('Access-Control-Allow-Credentials: true'); // header('P3P: CP="There is no P3P policy."'); // Sanitize input if (preg_match("/([^\w\s\d\-_~,;:\[\]\(\).])|([\.]{2,})/", $temp['name'])) { header("HTTP/1.1 400 Invalid file name."); return; } // Verify extension if (!in_array(strtolower(pathinfo($temp['name'], PATHINFO_EXTENSION)), array("gif", "jpg", "jpeg", "png"))) { header("HTTP/1.1 400 Invalid extension."); return; } // Accept upload if there was no origin, or if it is an accepted origin // If image is JPEG compress with GD library $filetowrite = $imageFolder . $temp['name']; if (in_array(strtolower(pathinfo($temp['name'], PATHINFO_EXTENSION)), array("jpg", "jpeg"))) { imagejpeg($temp['tmp_name'], $filetowrite, 75); } else { move_uploaded_file($temp['tmp_name'], $filetowrite); } // Respond to the successful upload with JSON. // Use a location key to specify the path to the saved image resource. // { location : '/your/uploaded/image/file'} // echo json_encode(array('location' => $filetowrite)); $passpath = $year.'/'.$month.'/'.$temp['name']; echo json_encode(array('location' => $passpath)); } else { // Notify editor that the upload failed header("HTTP/1.1 500 Server Error"); } ?>
Similar TutorialsIt's pretty simple to see what I am trying to do here. For some reason all results in the table are the same exact cityName replacing all existing records. The echoed results are correct. I've include a small dump of my table as well. $query = "SELECT cityName FROM sys_city_dev_2"; $resource = mysqli_query($cxn, $query) or die("MySQL error: " . mysqli_error($cxn) . "<hr>\nQuery: $query"); while($result = mysqli_fetch_assoc($resource)) { $nox = $result['cityName']; $toUpper = ucfirst($nox); echo "$toUpper" . "<br />"; $setString = "UPDATE sys_city_dev_2 SET cityName = '" . $toUpper ."' WHERE cityName != ''"; mysqli_query($cxn,$setString); } 100 Records of table dump (pre running my script above): -- -- Table structure for table `sys_city_dev_2_backup` -- CREATE TABLE IF NOT EXISTS `sys_city_dev_2_backup` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Mid` int(11) NOT NULL DEFAULT '0', `cityName` varchar(30) NOT NULL DEFAULT '', `forder` int(4) NOT NULL DEFAULT '0', `disdplay` int(4) NOT NULL DEFAULT '0', `cid` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=113970 ; -- -- Dumping data for table `sys_city_dev_2_backup` -- INSERT INTO `sys_city_dev_2_backup` (`ID`, `Mid`, `cityName`, `forder`, `disdplay`, `cid`) VALUES (84010, 1, 'dothan', 0, 0, 0), (84011, 1, 'alabaster', 0, 0, 0), (84012, 1, 'birmingham', 0, 0, 0), (84013, 2, 'flagstaff', 0, 0, 0), (84014, 1, 'auburn', 0, 0, 0), (84015, 1, 'florence', 0, 0, 0), (84016, 1, 'gadsden', 0, 0, 0), (84017, 1, 'huntsville', 0, 0, 0), (84018, 1, 'mobile', 0, 0, 0), (84019, 1, 'montgomery', 0, 0, 0), (84020, 1, 'tuscaloosa', 0, 0, 0), (84021, 2, 'mohave valley', 0, 0, 0), (84022, 2, 'phoenix', 0, 0, 0), (84023, 2, 'prescott', 0, 0, 0), (84024, 2, 'sierra vista', 0, 0, 0), (84025, 2, 'tucson', 0, 0, 0), (84026, 2, 'yuma', 0, 0, 0), (84027, 3, 'bakersfield', 0, 0, 0), (84028, 3, 'chico', 0, 0, 0), (84029, 3, 'fresno / madera', 0, 0, 0), (84030, 3, 'gold country', 0, 0, 0), (84031, 3, 'humboldt county', 0, 0, 0), (84032, 3, 'imperial', 0, 0, 0), (84033, 3, 'inland empire', 0, 0, 0), (84034, 3, 'los angeles', 0, 0, 0), (84035, 3, 'alhambra', 0, 0, 0), (84036, 3, 'merced', 0, 0, 0), (84037, 49, 'fayetteville', 0, 0, 0), (84038, 49, 'fort smith', 0, 0, 0), (84039, 49, 'jonesboro', 0, 0, 0), (84040, 49, 'little rock', 0, 0, 0), (84041, 49, 'arkadelphia', 0, 0, 0), (84042, 49, 'texarkana', 0, 0, 0), (84043, 3, 'modesto', 0, 0, 0), (84044, 3, 'alta sierra', 0, 0, 0), (84045, 3, 'alpine', 0, 0, 0), (84046, 3, 'pedley', 0, 0, 0), (84047, 3, 'redding', 0, 0, 0), (84048, 3, 'alondra park', 0, 0, 0), (84049, 3, 'sacramento', 0, 0, 0), (84050, 4, 'canon city', 0, 0, 0), (84051, 3, 'san luis obispo', 0, 0, 0), (84052, 3, 'santa barbara', 0, 0, 0), (84053, 3, 'stockton', 0, 0, 0), (84054, 3, 'aliso viejo', 0, 0, 0), (84055, 3, 'visalia', 0, 0, 0), (84056, 3, 'yuba city', 0, 0, 0), (84057, 4, 'boulder', 0, 0, 0), (84058, 4, 'colorado springs', 0, 0, 0), (84059, 4, 'denver', 0, 0, 0), (84060, 4, 'applewood', 0, 0, 0), (84061, 4, 'pueblo', 0, 0, 0), (84062, 4, 'air force academy', 0, 0, 0), (84063, 5, 'avon', 0, 0, 0), (84064, 5, 'hartford', 0, 0, 0), (84065, 5, 'new haven', 0, 0, 0), (84066, 5, 'ansonia', 0, 0, 0), (84067, 5, 'fairfield', 0, 0, 0), (84068, 7, 'daytona beach', 0, 0, 0), (84069, 7, 'sebastian', 0, 0, 0), (84070, 5, 'wallingford center', 0, 0, 0), (84071, 8, 'belvedere park', 0, 0, 0), (84072, 7, 'sarasota springs', 0, 0, 0), (84073, 7, 'sandalfoot cove', 0, 0, 0), (84074, 7, 'san carlos park', 0, 0, 0), (84075, 7, 'st. augustine', 0, 0, 0), (84076, 7, 'tallahassee', 0, 0, 0), (84077, 7, 'safety harbor', 0, 0, 0), (84078, 7, 'ruskin', 0, 0, 0), (84079, 8, 'athens-clarke county', 0, 0, 0), (84080, 8, 'atlanta', 0, 0, 0), (84081, 8, 'augusta-richmond county', 0, 0, 0), (84082, 8, 'brunswick', 0, 0, 0), (84083, 8, 'columbus', 0, 0, 0), (84084, 8, 'americus', 0, 0, 0), (84085, 8, 'acworth', 0, 0, 0), (84086, 8, 'valdosta', 0, 0, 0), (84087, 10, 'boise', 0, 0, 0), (84088, 10, 'ammon', 0, 0, 0), (84089, 10, 'moscow', 0, 0, 0), (84090, 10, 'blackfoot', 0, 0, 0), (84091, 10, 'twin falls', 0, 0, 0), (84092, 10, 'meridian', 0, 0, 0), (84093, 10, 'jerome', 0, 0, 0), (84094, 10, 'idaho falls', 0, 0, 0), (84095, 11, 'addison', 0, 0, 0), (84096, 10, 'garden city', 0, 0, 0), (84097, 10, 'eagle', 0, 0, 0), (84098, 10, 'chubbuck', 0, 0, 0), (84099, 10, 'caldwell', 0, 0, 0), (84100, 12, 'bloomington', 0, 0, 0), (84101, 12, 'evansville', 0, 0, 0), (84102, 12, 'fort wayne', 0, 0, 0), (84103, 12, 'indianapolis', 0, 0, 0), (84104, 12, 'muncie / anderson', 0, 0, 0), (84105, 12, 'lafayette / west lafayette', 0, 0, 0), (84106, 12, 'south bend / michiana', 0, 0, 0), (84107, 12, 'terre haute', 0, 0, 0), (84108, 12, 'northwest indiana', 0, 0, 0), (84109, 13, 'ames', 0, 0, 0); This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=326314.0 I am trying to find a good IDE for PHP and JavaScript. I fiddled around with Visual Code and it was very buggy. The GitHub page said over 800 open errors?!?!? Now I'm looking at PHPStorm and it reads that only PHP in a PHP page or JavaScript in a JavaScript page may be debugged. I am wondering if this is always possible to separate the code like this.
Also, in the following code, what do you all think about using a XMLHttpRequest() to call this right in the beginning of the page with no button or anything. Is this bad form? It creates a dropdown list from the database. Right now it just sits there. This code isn't ready for prepare yet.
<?php $host = 'localhost'; $user = 'root'; $pass = ''; $database = 'ecommerce'; $options = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false ); $dbo = new PDO("mysql:host=$host;dbname=$database", $user, $pass, $options); $q4 = "SELECT categories.title FROM categories INNER JOIN customers on customers.CustomerID = categories.CustomerID and customers.CustomerID = 1"; echo '<select id = "dropDown1" >'; foreach ($dbo->query($q4) as $row) { echo "<br>"; echo '<option value = " '; echo $row['title']; echo '">'; echo $row['title']; echo '</option>'; } echo "<br>"; echo '</select>'; ?> I'm using AJAX.
Edited January 2 by JoshEir This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=330095.0 I am making a pos(point of sale) application using object oriented php. I have found thermal receipt printers support ESC/POS . i want that when i will press button to print directly , it will do automatically. anyone can help me please. Thanks in advance. Hi guys,
Having some trouble entering some php into my wordpress site that runs on Optimize Press.
I'm trying to insert this URL/ tracking code into my page as a hyperlink - 'Click Here Now'.
http://www.mysite.co...1_50onRed&sub1=<?php echo $sub1; ?>&sub2=<?php echo $sub2; ?>&sub3=<?php echo $sub3; ?>&sub4=<?php echo $sub4; ?>&sub5=<?php echo $sub5; ?>&lpid=<?php echo $lpid; ?>
This is what I have done so far:
<a href="http://www.mysite.co...;sub1=<?php echo $sub1; ?>&sub2=<?php echo $sub2; ?>&sub3=<?php echo $sub3; ?>&sub4=<?php echo $sub4; ?>&sub5=<?php echo $sub5; ?>&lpid=<?php echo $lpid; ?>">Click Here Now</a>
This does generate a hyperlink, however when I click it, I get: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=' at line 2
I understand for this code to work the page has to be saved in php. I thought wordpress did this automatically?
Can anyone help please? Also, please bear in mind I am using the Optimize Press plugin.
Many thanks in advance!
Tom
I have a site that I have an about page with pictures of people on it. I would like to create something that would do the following: * When you click on one of the images, i need text for that image to load in a text area. I would like to do this rather than have to make a different HTML page for each person, but I am not sure how to go about doing it. I do not have a database for this site, so I will need to pull the text from a text file or something like that. Any ideas on how to get started would be helpful. Thanks in advance! I have a template written for me on another project that searches a MySQL database. I'm moving this template to work with a database that only have 10 records in it and instead of having a search option I would just like it to automatically display the database when the page opens. Is this possible? The php page in close to 200 lines. This is the line of the code that has the search option. If you need more I can post it. Thanks Bob Code: [Select] <div id="search"> <form action="parts.php" method="GET"> Search: <input type="text" value="'.htmlentities($_GET['s']).'" name="s"/> <input type="submit" value="Search!"/> </form> </div> Hi, how i could do this with gdlibrary: I make image with imagecreatefrompng , and that is my pictures background. Then I add image there, and that is my bird flying in the background. that is only example, i wanna just add image to image What do I need to do in order to use the libssh2 library? I'm trying to write a script that will copy images from one website (a supplier, in this case puma) and save them to the dealer's web server. I have already done this for other supplier's websites but puma uses png's instead of jpeg's and I believe that is what is causing my issues: The original image looks like this: The copied image some odd colors in the background like this: Here is the code: Code: [Select] $puma_image = "http://www.pumab2b.com/_static/images/styleColors/1234560002/" . str_replace(" ", "", $Item_Num) . "_1.png"; $image = imagecreatefrompng($puma_image); if ($image) { //Save image to Soccer Etc server (images folder): if (imagepng($image, "prod_images/" . $cur_Item['Item_Num'] . ".png", 0)) { //DO some other stuff here } } I just noticed after posting the original image on this forum, that it is actually transparent. I'm guessing this has something to do with my problems? Hi, I would like my users to create and save forms via mysql. They should be able to choose what field they want to use, and other users should be able to fill the forms into mysql. Any ideas on how to accomplish this? I want to get the ibase_blob_echo function and I was told I need to uncomment the extension=php_interbase.dll in my php.ini. So I did and now I get the message: Unable to Load Dynamic Library in a pop-up window. I'm lost and don't know how to solve this Hi everyone. There are two nice script which are advanced for me to understand. There is a Knockout tournament scheduler class that makes image of the bracket. and there is a code that makes html of the bracket with jquery. I want to use the class with jquery. but I don't know how to do that and where to start. the class below needs to implement to this http://whileonefork.blogspot.com/2010/10/jquery-json-to-draw-elimination-single.html I attached the php script. please help me! Code: [Select] <?php class KnockoutGD extends Knockout { private $im = null; // GD-lib image resource. private $tc = 0; // Text color. public function getImage($tourName = '') { /* Returns a GD-lib image resource */ // Initial testing. if (empty($this->roundsInfo)) return null; // Dimensional parameters. $fh = imagefontheight(FONT); $fw = imagefontwidth(FONT); $lpad = 30; // Line (branch) padding before and after competitor names and after scores. $hpad = 20; // Outer horizontal image padding. $vpad = 60; // Outer vertical image padding. $lw = $this->getStrLen()*$fw + 3*$lpad; // Line (branch) width. Where getStrLen() gets the length of the longest string used in the image. // Initial calls. $dimensions = $this->getDimens($fh, $lw, $hpad, $vpad); $this->im = imagecreate($dimensions['x'], $dimensions['y']); $bg = imagecolorallocate($this->im, 255, 255, 255); // Set background color. $this->tc = imagecolorallocate($this->im, 0, 0, 0); // Text color. $this->mkStr($dimensions['x'] - $hpad - imagefontwidth(LFONT)*strlen($tourName), $dimensions['y'] - $vpad/2, $tourName, LFONT); // Print tournament name. // Initial positioning values from which drawing begins. $rx = $hpad; // Round X-position. $ry = $vpad; // Round Y-position. $depth = 1; // Branch depth. // Start drawing the tournament bracket/tree. foreach ($this->roundsInfo as $r => $info) { $n = $info[1]; // Number of expected players in round $r. // If a match is no yet created, then a placeholder is made so that the bracket structure is still printable. for ($m = 0; $m <= $n/2 - 1; $m++) { if (!$this->isMatchCreated($m, $r)) { $this->bracket[$r][$m]['c1'] = $this->bracket[$r][$m]['c2'] = null; $this->bracket[$r][$m]['s1'] = $this->bracket[$r][$m]['s2'] = -1; } } // Now we generate round branches. $x = $rx; $y = $ry; $bheight = pow(2, $depth) * $fh; // This is the height of a match-branch, which increases as the tree depth increases. ksort($this->bracket[$r]); foreach ($this->bracket[$r] as $m) { for ($i = 1; $i <= 2; $i++, $y += $bheight) { $this->mkStr($x+$lpad, $y, $m['s'.$i] == -1 ? 'Undecided' : $m['c'.$i]); $this->mkStr($x+$lw-$lpad, $y, $m['s'.$i] == -1 ? '?' : $m['s'.$i]); $this->mkLine($x, $y+$fh, $x+$lw, $y+$fh); } $this->mkLine($x+$lw, ($y+$fh)-$bheight, $x+$lw, ($y+$fh)-2*$bheight); } // Get ready for next loop. $rx += $lw; $ry += $bheight/2; $depth++; } // Add final branch/line for the tournament winner $fr = end(array_keys($this->roundsInfo)); // Final round. $s1 = $this->bracket[$fr][0]['s1']; $s2 = $this->bracket[$fr][0]['s2']; $winner = (!array_key_exists(0, $this->bracket[$fr]) || $s1 == -1 || $s2 == -1 || $s1 === $s2) ? '?' : (($s1 > $s2) ? $this->bracket[$fr][0]['c1'] : $this->bracket[$fr][0]['c2']); $this->mkStr($rx+$lpad, $ry, 'Winner: ' . $winner); $this->mkLine($rx, $ry+$fh, $rx+$lw, $ry+$fh); // Now, we print the round titles. array_push($this->roundsInfo, array('Champion', 1)); // Add fictitious round for printing purposes only. foreach (array_reverse($this->roundsInfo) as $r) { $this->mkStr($rx+$lpad, $vpad/3, $r[0], LFONT); $rx -= $lw; // Move back one round/column. } array_pop($this->roundsInfo); // Remove fictitious round entry again. return $this->im; } private function mkLine($x0, $y0, $x, $y) { /* Wrapper for function that creates a line. */ imageline($this->im, $x0, $y0, $x, $y, $this->tc); } private function mkStr($x, $y, $str, $font = false) { /* Wrapper for function that writes a string. */ imagestring($this->im, $font ? $font : FONT, $x, $y, $str, $this->tc); } private function getDimens($fontHeight, $lineWidth, $horizPad, $vertPad) { /* Returns image dimensions based on the tournament bracket. */ /* Vertically: Each match-branch is outputted like this: Team A ----------- Padding Team B ----------- Padding ... where "Padding" and "Team X" are of height $fontHeight, and "------" are branch lines with approximately no height. Horizontally: Each branch is outputted like this: ----- Team A ------ | ----- Team C ------ | ----- Team B ------ ... where "Team X" branch has an absolute length of $lineWidth. The above therefore illustrates a length of 2*$lineWidth. The image length, $x, must be: $horizPad + number_of_rounds * $lineWidth + $horizPad And the image height, $y, must be: $vertPad + number_of_matches_in_first_round * 4*$fontHeight + $vertPad ... since the first round contains the most matches. */ $frGames = count($this->bracket[1]); // Number of games in the first round. $playInExists = !empty($this->bracket[0]) ? true : false; /* The y-size of the image must be calculated accordingly to the above description. Though, if a play-in round exists, then the play-in round is potentially the round which requires the most vertical space to draw. In this case we scale the image as if the play-in round was the first round. Due to the nature of the tournament bracket, this means that there are twice as many games in that round. */ $y = 2*$vertPad + ($playInExists ? $frGames*2 : $frGames) * 4*$fontHeight; /* The x-size of the image is proportional to the number of rounds in the tournament, where the proportionality constant is the length of a branch, $lineWidth, ie. the width of a round. Since the number of players in the first round is equal to 2^R, where R is a whole number, and denotes the number of rounds required in the tournament, then R = log(players, 2), where "players" also can be found by 2 * matches_in_first_round (2 players pr. match). Like above, if a play-in round exists the x-size of the image must be changed. In this case, we merely add the length of a branch to the total x-size, since all branches are equal in length. Besides that, we add another whole branch length for the Winner/Champion branch, which technically is not a part of the tournament bracket, but is shown anyway. */ $x = 2*$horizPad + (log($frGames*2, 2) + ($playInExists ? 1 : 0) + 1) * $lineWidth; return array('x' => $x, 'y' => $y); } private function getStrLen() { /* Returns the length of longest string used in either rounds. This is done by looking in both play-in round and first round, since all competitors are to be found there. */ $len = 0; foreach (array_merge(array_key_exists(0, $this->bracket) ? $this->bracket[0] : array(), $this->bracket[1]) as $m) { if (($newlen = strlen($m['c1'])) > $len) $len = $newlen; if (($newlen = strlen($m['c2'])) > $len) $len = $newlen; } foreach ($this->roundsInfo as $arr) { if (($newlen = strlen($arr[0])) > $len) $len = $newlen; } return $len; } } ?> Hello everyone, What is the best way to take HTML formatted text and overlay it on a image (presumably using php's GD functions)? Unfortunately, HTML tags are ignored and any kind of code is treated as plaintext by imagefttext(). However, I need this HTML DIV box pasted onto an image and I intend to get it done. To make things slightly worst, this is a dynamic, PHP generated DIV box. I had an idea of utilizing some kind of buffering to generate my DIV box, convert that DIV box to an image and finally paste it onto my image using the GD library. If that sounds like a reasonable idea, can someone please help me get started? Thanks in advance, guys!
How to implement the library
here's my code <?php include("../incs/config.php"); $result = mysqli_query($link, "SELECT * FROM press ORDER BY press_date DESC"); $result2 = mysqli_query($link, "SELECT * FROM event ORDER BY event_date DESC"); $result3 = mysqli_query($link, "SELECT * FROM galleries ORDER BY gallery_id DESC"); if (!isset($_COOKIE['user'])) { die("Identifiant invalide"); } ?> <!DOCTYPE html><html> <head><meta charset='UTF-8'> <meta name="robots" content="noindex"> </head> <html> <head> <link rel="stylesheet" href="../css/bootstrap.min.css"> <link rel="stylesheet" href="../css/jquery-ui.css"> <link href="../stylesheets/style.css" rel="stylesheet"> <link href="stylesheets/style.css" rel="stylesheet"> <script src="../js/jquery-migrate.min.js"></script> <script src="../js/jquery.min.js"></script> <script src="../js/jquery.ui.js"></script> <script src="../js/bootstrap.min.js"></script> <script src="../js/tinymce/js/tinymce/tinymce.min.js"></script> </head> <body> <!-- header --> <header> <!-- nav --> <nav class="navbar navbar-default"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="../index.php"><img src="../images/logo.png" alt="Louise Groux"></a> </div><!-- / navbar-header --> <div> <ul class="nav nav-pills navbar-nav" style="font-weight:bold; padding-left:25px;"> <li class="active"><a href="#presse-2" data-toggle="pill"><i class="fa fa-home"></i> Presse </a></li> <li><a href="#evenements-2" data-toggle="pill"><i class="fa fa-comments"></i> Événements </a></li> <li><a href="#galerie-2" data-toggle="pill"><i class="fa fa-cloud"></i> Galerie</a></li> </ul> </div><!--/ nav-collapse --> </div><!-- / container --> </nav> <!-- / nav --> </header> <!-- / header --> <!--<div class="container-fluid"> <div class="row"> <a class="navbar-brand" href="../index.php"><img src="../images/logo.png" alt="logo" width="50" height="50"></a> </div> </div> --> <div class="container content-sm"> <!-- Tab v3 --> <div class="row tab-v3"> <div class="col-sm-9"> <div class="tab-content"> <div class="tab-pane fade in active" id="presse-2"> <div class="container col-md-12""> <h1>Presse</h1> <div style="text-align:center;margin:40px;">Veuillez utiliser la page pour mettre à jour, ajouter et supprimer des articles de presse. Faites glisser pour changer l'ordre et n'oubliez pas de sauvegarder une fois terminé !</div> <ul class="list-unstyled"> <li class="panel panel-info"> <div class="panel-heading"> <h5></h5> </div> <div class="panel-body"> <form action="presse/add.php" method="post" name="form1" enctype="multipart/form-data"> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="title">Tit </label> <div class="col-sm-10"> <input type="text" class="form-control" name='title' id="title" > </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="sub_title">Sous-tit </label> <div class="col-sm-10"> <input type="text" class="form-control" name='sub_title' id="sub_title"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="press_date">Date (invisible, pour l'ordre de la liste):</label> <div class="col-sm-10"> <input type="text" class="form-control datepicker" name='press_date' id="press_date"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Gen </label> <div class="col-sm-10"> <input type="text" class="form-control" name='type' id="type" > </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Lien:</label> <div class="col-sm-10"> <input type="text" class="form-control" name='link' id="link"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Image (150px x 150px): </label> <div class="col-sm-10"> <input class="input-group" type="file" name="image"/> </div> </div> </div> <input type="submit" name="Submit" class="btn btn-louisegroux pull-right" value="Ajouter"></button> </form> </div> </li> </ul> <?php if ($result->num_rows > 0) { //<button class="save btn btn-louisegroux">Sauvegarder l'ordre des éléments</button> } ?> <div id="accordion-resizer" class="ui-widget-content"> <div id="accordion"> <ul id="draggablePanelList" class="sortable press_sort list-unstyled"> <?php while ($res = mysqli_fetch_array($result)) { $title = $res['title']; $sub_title = $res['sub_title']; $press_date = $res['press_date']; $type = $res['type']; $news_link = $res['link']; $image = $res['image']; $id = $res['id']; $title = stripslashes($title); $sub_title = stripslashes($sub_title); ?> <li name='item' id='item-<?php echo "$id"; ?>' class="panel panel-info""> <div class="panel-heading"> <h3 class="panel-title pull-left"> <?php echo "$title"; ?><span>, </span><?php echo "$sub_title"; ?> </h3> <a href="presse/delete.php?id=<?php echo "$id"; ?>"; ><button class="btn btn-danger clickable pointer pull-right" data-effect="remove"><span class="glyphicon glyphicon-remove"></span></button></a> <div class="clearfix"></div> </div> <div class="panel-body"> <form name="form1" action=presse/edit.php?id="<?php echo "$id"; ?>" method="post" enctype="multipart/form-data"> <div class="col-md-3"> <div class="form-group"> <?php if ($image != "") { ?> <img src="../images/presse/<?php echo "$image"; ?>" class="img-responsive" style="max-height:150px; max-width:150px;"> <?php } ?> <div class="clearfix"></div> <input class="input-group" type="file" name="image"/> </div> </div> <div class="col-md-9"> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="title">Tit </label> <div class="col-sm-10"> <input type="text" class="form-control" name='title' id="title" value="<?php echo "$title"; ?>"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="title">Sous-tit </label> <div class="col-sm-10"> <input type="text" class="form-control" name='sub_title' id="sTitle" value="<?php echo "$sub_title"; ?>"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="press_date">Date (invisible, pour l'ordre de la liste):</label> <div class="col-sm-10"> <input type="text" name="press_date" value="<?php echo "$press_date"; ?>"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Gen </label> <div class="col-sm-10"> <input type="text" class="form-control" name='type' id="type" value="<?php echo "$type"; ?>"> </div> </div> </div> <div class="form-horizontal"> <div class="form-group"> <label class="control-label col-sm-2" for="type">Lien:</label> <div class="col-sm-10"> <input type="text" class="form-control" name='link' id="link" value="<?php echo "$news_link"; ?>"> </div> </div> </div> </div> <input type="hidden" name="id" value="<?php echo "$id"; ?>"> <input type="hidden" name="old_image" value="<?php echo "$image"; ?>"> <button type="submit" name="update" class="btn btn-louisegroux pull-right">Mettre à jour</button> </form> </div> </li> <?php } ?> Edited October 16, 2019 by samplephp hi, i'm using the fpdf library to generate PDF's from form input. It all worked well on my local host, but now that i have transferred to a web server it displays the following error when trying to generate a PDF. Warning: require(/fpdf16/fpdf.php) [function.require]: failed to open stream: No such file or directory in /home/ddgq0o2n/public_html/quote_builder/pdf.php on line 2 Fatal error: require() [function.require]: Failed opening required '/fpdf16/fpdf.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/ddgq0o2n/public_html/quote_builder/pdf.php on line 2 i have searched for "include_path", but can't find it anywhere. i'm thinking it's a server problem, where the library may not be compatible or something needs to be switched on, as it worked fine on my local host. any help and suggestions welcome thanks. Font size GD Library Hi All I'm trying to create a font tester - http://www.ttmt.org.uk/fonts/index.php (this demo doesn't use the font I'm using.). I'm using the GD library to create images of the text. I'm not happy with the quality of the fonts at small sizes. I've tried everything to fix it but nothing is working. One suggestion I had was to create the fonts larger then reduce the size of the image. Can anyone offer any advise how I might do this? Code: [Select] <?php header('Content-Type: image/png'); $im = imagecreatetruecolor(1000, 200); $gray = imagecolorallocate($im, 240, 240, 240); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 1000, 199, $gray); $text = $_GET['text']; $textSize = $_GET['size']; $font = $_GET['font']; imagefttext($im, $textSize, 0, 15, 160, $black, $font, $text); imagepng($im); imagedestroy($im); ?> Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>untitled</title> <style type="text/css"> *{margin:0;padding:0;} #wrap{margin:20px 0 0 20px;} h1{margin:0px 0 20px 0;clear:both;} h2{font-size:1.1em;margin:15px 0 5px 0;} #top{padding:0 0 20px 0;} form{margin:0 0 20px 0;} </style> </head> <body> <div id="wrap"> <form action="index.php" method="post"> <!--<input type="text" name="text" value="<?php echo $_POST['text'];?>" />--> <select name="text" > <option value="<?php echo $_POST['text'];?>">Text</option> <option value="ABCDEFGHIJKLMNOPQRSTUVWXYZ">ABCDEFGHIJKLMNOPQRSTUVWXYZ</option> <option value="abcdefghijklmnopqrstuvwxyz">abcdefghijklmnopqrstuvwxyz</option> <option value="0123456789">0123456789</option> </select> <select name="size"> <option value="<?php echo $_POST['size'];?>">Size</option> <option value="10">10</option> <option value="12">12</option> <option value="14">14</option> <option value="18">18</option> <option value="24">24</option> <option value="30">30</option> <option value="38">38</option> <option value="42">42</option> <option value="50">50</option> <option value="60">60</option> <option value="80">80</option> <option value="100">100</option> </select> <input type="submit" name="submit" value="Set →" /> </form> <div id="top"> <?php $theFont="corbelb.ttf"; if(!empty($_POST['submit'])){ $myText = $_POST['text']; $mySize = $_POST['size']; echo '<img src="imageftt.php?text='.$myText.'&size='.$mySize.'&font='.$theFont.'">'; }else{ $myText = "Handgloves"; $mySize = 24; echo '<img src="imageftt.php?text='.$myText.'&size='.$mySize.'&font='.$theFont.'">'; } ?> </div> </div> </body> </html> I want to create a media library in the CMS, similar to how it is in WordPress but custom-coded in PHP on my own site. Can this be done simply with a database connection or will the images need to be uploaded to a server? Bit confused as to how it works and which is the best way to go about it. Thanks for any help. Edited January 12 by Richie1209I am trying to create a basic image with GD library, but my browser says that the image cannot be displayed because it contains errors... I have no idea why. Here's my code: Code: [Select] switch($_GET['case']){ case "progressbar": header('Content-Type: image/jpeg'); $barWidth = 6; $barHeight = 14; $barPadding = 2; $imageWidth = ($barWidth * 10) + (10 * $barPadding); $imageHeight = ($barHeight + ($barPadding * 2)); $img = @imagecreate($imageWidth, $imageHeight); $imgBorder = imagecolorallocate($img, 0, 0, 0); //imagefilledrectangle($img, 1, $imageHeight -1, $imageWidth - 1, $imageHeight - 1, $imgBorder); $output = "Hello, world!"; imagestring($img, 1, 4, 4, $output, $imgBorder); imagejpeg($img); imagedestroy($img); break; } I have a file called image.php that i use to create images and I use the URL image.php?case=progressbar. |